Need help

i need help guys !!
i want to rotate an array 1 dimension (unidimensionnel) to 90 degree

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


What are you trying to say?
Last edited on
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.
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.


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
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

plzz help to define this function !!

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...
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
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.
but the question asking for 1d array only unidimensionnel
You can *pretend* that it is a 2D array even though it is 1D.
That's what I've been trying to show OP. A 1D array can be treated as 2D pretty easily
i tried many times ti fix but i didnt got something !!

can you help me to define this function !!
Show me what you got so far
Topic archived. No new replies allowed.