MCPcopy Create free account
hub / github.com/Ayush7614/Daily-Coding-DS-ALGO-Practice / rotate90Clockwise

Method rotate90Clockwise

Gfg/Java/rotate matrix.java:10–28  ·  view source on GitHub ↗
(int a[][])

Source from the content-addressed store, hash-verified

8
9// Function to rotate the matrix 90 degree clockwise
10static 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
31static void printMatrix(int arr[][])

Callers 1

mainMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected