Click here to Skip to main content
13,298,348 members (69,644 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I need to implement a for loop to generate an image animation. As shown in the attached image[^] , 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
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.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

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];
      if (r == c)

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.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.171207.1 | Last Updated 17 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100