I'm having some trouble keeping this array in bounds. I have a 10x10 array that I print out on screen. I call a function that changes the center value [5][5] and the values below/to the right/left of this center value. [j+1] [i-1][j+1], etc.. So the values constantly change and constantly move down towards the bottom of this 10x10 grid. I need to call the function many times to keep changing the values, however, once the values reach the very bottom of the grid they want to appear at the top and start moving down towards the middle. I need the values to stop at the bottom, the changes need to keep applying, but no wrapping from the top.

ie:


0  0  0  0  0
0  0  5  0  0
0  2  3  2  0
1  2  2  2  1

The function continues to get called and these values keep changing and progressing, but they never wrap. Whereas this is the problem I'm having:

0 2  2  3  0
1 1  1  2  1
0 0  0  0  0
0 0  5  0  0
1 2  3  3  2
1 1  1  1  1

I'm aware the number of cells is different, just getting the point across. Any help or tips would be greatly appreciated.

Post your code.. Don't forget teh code tags.
Attach if it's big.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.