Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* http://hsin.hr/skolska2008/pasccpp1_zadaci.pdf */
- #include <iostream>
- using namespace std;
- main()
- {
- int n, m, a[3][3];
- int s = 1;
- for (int i=0; i<3; i++)
- for (int j=0; j<3; j++)
- {a[i][j] = s; s++;}
- cin >> n;
- for (int i=0; i<n; i++)
- {
- cin >> m;
- switch(m)
- {
- case 1:
- {
- s = a[0][0];
- a[0][0] = a[1][0];
- a[1][0] = a[1][1];
- a[1][1] = a[0][1];
- a[0][1] = s;
- } break;
- case 2:
- {
- s = a[0][1];
- a[0][1] = a[1][1];
- a[1][1] = a[1][2];
- a[1][2] = a[0][2];
- a[0][2] = s;
- } break;
- case 3:
- {
- s = a[1][0];
- a[1][0] = a[2][0];
- a[2][0] = a[2][1];
- a[2][1] = a[1][1];
- a[1][1] = s;
- } break;
- case 4:
- {
- s = a[1][1];
- a[1][1] = a[2][1];
- a[2][1] = a[2][2];
- a[2][2] = a[1][2];
- a[1][2] = s;
- } break;
- }
- }
- for (int i=0; i<3; i++)
- {
- for (int j=0; j<3; j++)
- cout << a[i][j] << " ";
- cout << endl;
- }
- system ("PAUSE");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement