| 8 | |
| 9 | // Function to rotate the matrix 90 degree clockwise |
| 10 | static void rotate90Clockwise(int a[][]) |
| 11 | { |
| 12 | |
| 13 | // Traverse each cycle |
| 14 | for (int i = 0; i < N / 2; i++) |
| 15 | { |
| 16 | for (int j = i; j < N - i - 1; j++) |
| 17 | { |
| 18 | |
| 19 | // Swap elements of each cycle |
| 20 | // in clockwise direction |
| 21 | int temp = a[i][j]; |
| 22 | a[i][j] = a[N - 1 - j][i]; |
| 23 | a[N - 1 - j][i] = a[N - 1 - i][N - 1 - j]; |
| 24 | a[N - 1 - i][N - 1 - j] = a[j][N - 1 - i]; |
| 25 | a[j][N - 1 - i] = temp; |
| 26 | } |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | // Function for print matrix |
| 31 | static void printMatrix(int arr[][]) |