CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2007
    Posts
    100

    Help coming up with stupid loop.

    I am trying to come up with a loop to overlap a 4X4 "box" array onto a a jar of larger size starting at row = 0 and col = 3 on the jar. Here is my last attempt, but I can't get it (firstcol=3/firstrow=0):

    Code:
    				for(int m=0;m<4;m++)
    				{
    					for(int n=0;n<4;n++)
    						for(int x=firstRow;x<firstRow+4;x++)
    						//for(int y=firstCol;y<firstCol+4;y++)
    						{
    							jar[x][m] = box[n][m];
    
    						}
    				}
    can anyone suggest a solution?--that would be MUCH appreciated.

  2. #2
    Join Date
    Jun 2004
    Location
    Scotland
    Posts
    59

    Re: Help coming up with stupid loop.

    Hi,

    You want to copy all of 'box' into 'jar', right?

    I think you just need the first 2 loops as you have them, and inside that put something like:

    jar[n + firstCol][m + firstRow] = box[n][m];

    Or maybe I misunderstood what you want to do.

    Cheers,
    Alan

  3. #3
    Join Date
    Sep 2007
    Posts
    100

    Re: Help coming up with stupid loop.

    yeah, box into jar.

  4. #4
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Re: Help coming up with stupid loop.

    [ Moved thread ]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured