Click to See Complete Forum and Search --> : Help coming up with stupid loop.


frasifrasi
December 8th, 2007, 02:41 PM
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):


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.

alanjhd
December 8th, 2007, 03:15 PM
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

frasifrasi
December 8th, 2007, 03:36 PM
yeah, box into jar.

ovidiucucu
December 8th, 2007, 10:03 PM
[ Moved thread ]