# Thread: Ordering an array in a 'strange' order.

1. ## Ordering an array in a 'strange' order.

Hello there. Im new to the forum, this is my first post, it will be quick i guess =]

I want to read an array in a different order and cant think the algh to do that. Heres what i wanna do in a [3][3] simple example. The array AWAYS will be a square. (x=y)

Code:
```  int array[3][3] = {{4,2,1},
{7,5,3},
{9,8,6}};```
Lets say i want to printf() the array number in the normal order ( 1 2 3 4... ). How could i do the algh that does this ?

This way i could generate 5 lines.

1
2 - 3
4 - 5 - 6
7 - 8
9

and that is what im after. Thanx for any replys.

[]īs Ziden

2. There was a thread on this recently.
zigzag traverse a matrix

3. thx for the reply.

He made a zig zag order, witch i belive is harder then what ive expecting, and not functional to what im intenting to do. Ill give a look and study his code but i belive is beyond my intellect to do this, thats y im desperate for help =(

What i really need is to 'walk' thro the array in that order and separate each line as i mentioned.

4. I figured out a simple way to solve this but still i cannot solve it, its impressive.

If j is controllin the matriz colums, the idea of inverting it would be instead of using J, using MaxJ - J so i would invert the colum side of reading order, but i just cant do it... ive tryed many ways n cannot do it. I beg for help.

Popular pages Recent additions