-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path48.cpp
More file actions
executable file
·30 lines (30 loc) · 852 Bytes
/
48.cpp
File metadata and controls
executable file
·30 lines (30 loc) · 852 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <vector>
using namespace std;
class Solution {
public:
void rotate(vector<vector<int> >& matrix) {
int left = 0;
int right = matrix.size();
while (left < right) {
int tmp = left;
while (tmp < right-1) {
int times = 0;
int i = left; int j = tmp;
int tmpstore = matrix[i][j];
while (times <= 3){
int midtmp = tmpstore;
tmpstore = matrix[j][matrix.size()-i-1];
matrix[j][matrix.size()-i-1] = midtmp;
midtmp = i;
i = j;
j = matrix.size()-midtmp-1;
times ++;
}
//left,tmp
tmp++;
}
left++;
right--;
}
}
};