You
are given an n x n 2D matrix representing an image.
Rotate
the image by 90 degrees (clockwise).
Follow
up:
Could you do this in-place?
class Solution {
public:
void rotate(vector<vector<
int> > &matrix) {
int n=matrix.size();
vector<vector<
int>> newm;
vector<
int> v;
for(
int i=
0;i<n;i++)
{
v.clear();
for(
int j=
0;j<n;j++)
v.push_back(matrix[n-j-
1][i]);
newm.push_back(v);
}
matrix= newm;
}
};
Rotate Image,布布扣,bubuko.com
Rotate Image
原文:http://www.cnblogs.com/erictanghu/p/3759372.html