12,634,107 members (23,682 online)
Rate this:
See more:
I need to implement a for loop to generate an image animation. As shown in the attached imagehttp://i.stack.imgur.com/VCjKW.jpg[^] , if a user selects hbox=6 and vbox=4, an a 2-d array of 24 items will be created. Now we need to access these elements as follows:

1st iteration: [1][1]
2nd iteration: [2][1], [1][2]
3rd: [3][1],[2][2],[1][3]
4th: [4][1],[3][2],[2][3],[1][4]
5th: [4][2],[3][3],[2][4],[1][5]
and so on until the last iteration is [4][6]

So please provide me a for loop implementation to access the elements in such fashion.
Posted 17-Feb-13 7:34am
Updated 17-Feb-13 7:38am
v2
Sergey Alexandrovich Kryukov 17-Feb-13 12:57pm

This is not a good question. You need to explain what you try to achieve clearly. Please understand that example is not a formulation of a problem.
—SA

Rate this:

## Solution 1

i just satisfy upto 4th iterations of your exmaple. The code is
```int hbox = 6;
int vbox = 4;
for (int r = 1; r <= hbox; r++)
{
int x = 0;
for (int c = 1; c <= vbox; c++)
{
string val = arr[r - x, c];
x++;
if (r == c)
break;
}
}```

But if 5th iteration i do not clear the varying part. There i saw row no is still same for iteration 4 and iteration 5. This requirement is little confused me. let me know the code will help you or not.
v2

Top Experts
Last 24hrsThis month
 OriginalGriff 320 Peter Leow 190 CHill60 105 CPallini 100 Jochen Arndt 80
 OriginalGriff 2,324 ppolymorphe 1,282 Peter Leow 1,004 John Simmons / outlaw programmer 725 CPallini 641