Jul 20, 2010 at 3:35am
It's not a rotation at all, it's a series of swaps.
Jul 20, 2010 at 5:28am
Yeap!
-----------------------[X O O]
Swap these two - [O O O]
-----------------------[O O X]
-----------------------[O X O]
Then these two - [O O O]
-----------------------[O X O]
-----------------------[O O X]
Then these two - [O O O]
-----------------------[X O O]
-----------------------[O O O]
Then these two - [X O X]
-----------------------[O O O]
And you're done!
EDIT:
Or you could just do this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
#include <iostream>
using namespace std;
int main()
{
int x[3][3]={1,2,3,4,5,6,7,8,9};
for (int i=2; i>=0; i--)
{
for (int j=2; j>=0; j--)
cout << x[i][j] << " ";
cout << " " << endl;
}
cin.get();
return 0;
}
|
Last edited on Jul 20, 2010 at 5:33am