Need help

Nov 1, 2012 at 4:05pm
i need help guys !!
i want to rotate an array 1 dimension (unidimensionnel) to 90 degree

void RotateImg90(int aToCompareReduced[], int &cRowRef, int &cColRef)???

Nov 1, 2012 at 4:36pm
wtf.

What are you trying to say?
Last edited on Nov 1, 2012 at 4:40pm
Nov 1, 2012 at 4:44pm
He has a 1D array that contains a 2D image and he wants to rotate that image 90 degrees, and he doesn't care if it gets rotated clockwise, counterclockwise, or one of those at random.
Nov 1, 2012 at 4:48pm
How would you do it in a 2D array? If you can do that, you can translate that to a 1D array, as a 2D array is really just a 1D array being represented to you differently. Here's a 2D array, being represented with 1D indices.

012
345
678

Each 3 indices starts a new "row" of the array. This is really all 2D arrays are. If you access element [1][0] here, the back end is just saying "Ok, let's access element [3(1) + 0]."
Last edited on Nov 1, 2012 at 4:49pm
Nov 1, 2012 at 5:31pm
actually i dont know how to do it with 2 D array !!! i want 90 deg in clockwise sens

void RotateImg90(int array[], int &Row, int Col)??? this is the prototype of the function

Row its number of rows
col its numbre of columns
array[Row*Col]

plzz help to define this function !!

Nov 1, 2012 at 5:37pm
Ok look at it like this:

Original array =

1 2 3
4 5 6
7 8 9

Rotated 90 degrees =

3 6 9
2 5 8
1 4 7

Can you see what happened there? It took the final column and made it the first row, second to last column because the second row, third to last column because third row, etc...
Nov 1, 2012 at 5:41pm
accually it like this:

Original array =

1 2 3 4
5 6 7 8

Rotated 90 degrees clockwise


5 1
6 2
7 3
8 4
Nov 1, 2012 at 5:48pm
The same logic applies. The new array assumes size of [oldY][oldX] where oldArr[oldX][oldY], and then you just assign values as I said above.
Nov 1, 2012 at 7:40pm
but the question asking for 1d array only unidimensionnel
Nov 1, 2012 at 8:23pm
You can *pretend* that it is a 2D array even though it is 1D.
Nov 1, 2012 at 11:48pm
That's what I've been trying to show OP. A 1D array can be treated as 2D pretty easily
Nov 2, 2012 at 2:59am
i tried many times ti fix but i didnt got something !!

can you help me to define this function !!
Nov 2, 2012 at 3:30pm
Show me what you got so far
Topic archived. No new replies allowed.