标签:
class Solution {
public:
void rotate(vector<vector<int> > &matrix) {
int length = matrix.size();
for (int i = 0; i < length/2; i++)
{
for (int j = i; j < length - i - 1; j++)
{
int tmp = matrix[i][j];
matrix[i][j] = matrix[length - j - 1][i];
matrix[length - j - 1][i] = matrix[length - i - 1][length - j - 1];
matrix[length - i - 1][length - j - 1] = matrix[j][length - i - 1];
matrix[j][length - i - 1] = tmp;
}
}
}
};
标签:
原文地址:http://www.cnblogs.com/flyjameschen/p/5d92c59daba1cc6b261b48be661bd118.html