Skip to content

Commit 71a30d7

Browse files
author
王俊超
committed
commit
1 parent 8004fe7 commit 71a30d7

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

.idea/modules.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* @author: wangjunchao(王俊超)
3+
* @time: 2018-09-28 15:31
4+
**/
5+
public class Solution {
6+
public void rotate(int[][] matrix) {
7+
int temp;
8+
9+
// 先做y=x对称转换
10+
for (int i = 0; i < matrix.length; i++) {
11+
for (int j = i; j < matrix.length; j++) {
12+
temp = matrix[i][j];
13+
matrix[i][j] = matrix[j][i];
14+
matrix[j][i] = temp;
15+
}
16+
}
17+
18+
// 再对行进行水平转换
19+
int half = matrix.length / 2;
20+
for (int i = 0; i < matrix.length; i++) {
21+
for (int j = 0; j < half; j++) {
22+
temp = matrix[i][j];
23+
matrix[i][j] = matrix[i][matrix.length - 1 - j];
24+
matrix[i][matrix.length - 1 - j] = temp;
25+
}
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)