Possible Duplicate:
How do you rotate a two dimensional array?
Beginner in C++ , Need to rotate to 90 degrees, I already tried to do with the help of others posts here , but without luck. Sorry for English
# define D 9
int Ta [D][D];
short i, j;
short c=1;
for ( i=0; i < D ; i++) {
for ( j = 0 ; j < D; j++)
if ((j>i) && (j<D-i-1)) Ta[i][j]=c++;
else if((j>D-i-1) && (j<i)) Ta[i][j]=c++;
else Ta[i][j]=0;
}
for ( i = 0; i < D; i++) {
for ( j= 0; j < D; j++) {
printf("%3d",Ta[i][j]);
}
printf("\n");
}
the answer was : Thanks to Adam Liss
int r[D][D];
for (i=0; i<D; ++i) {
for (j=0; j<D; ++j) {
r[i][j] = t[D-j-1][i];
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With