Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void rotate(int arr[][3], int n)
- {
- int tmp[3][3];
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < n; j++) {
- tmp[j][n - 1 - i] = arr[i][j];
- }
- }
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < n; j++) {
- cout << tmp[i][j] << " ";
- }
- cout << endl;
- }
- }
- int main() {
- int arr[3][3] = { {1,2,3},{4,5,6},{7,8,9} };
- rotate(arr, 3);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement