Need help

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

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

Code Assassin (295)
wtf.

What are you trying to say?
Last edited on
L B (3327)
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.
ResidentBiscuit (2215)
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
scofield1234 (5)
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 !!

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

can you help me to define this function !!
ResidentBiscuit (2215)
Show me what you got so far
Registered users can post here. Sign in or register to post.