0

Hi! I make c++ programm for school and I have problem with array rotation for 90 degree. I make array rotation from one example, but there is an array rotation on wrong way, I need to make it to rotate to other way. So please help me. Here is code:

//array mas[100][100]
                     j=i; // this is cube array size like i=100;
                     for (n=0; n<=j/2; n++)
                     {
                        for (m=0; m<=j-1; m++)
                        {
                                x=n;
                                y=m;
                                tmp=mas[j-n+1][m];
                                mas[j-n+1][m]=mas[y][x];
                                tmp2=mas[j-m+1][j-n+1];
                                mas[j-m+1][j-n+1]=tmp;
                                tmp=mas[x][j-m+1];
                                mas[x][j-m+1]=tmp2;
                                mas[y][x]=tmp;
                        }
                     }

Here is input (example):
2 6
3 9

Here is output:
6 9
2 3

Needed output (I need this output):
3 2
9 6

2
Contributors
1
Reply
3
Views
7 Years
Discussion Span
Last Post by Clinton Portis
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.