首页 > 代码库 > Leetcode048. Rotate Image

Leetcode048. Rotate Image

//鬼晓得上下反转,对角翻转之后竟然正好顺时针九十度,数学事体育老师教的
class
Solution {public: void rotate(vector<vector<int>>& matrix) { if(matrix.size()==0)return ; int size=matrix.size(); for(int i=0;i<size/2;i++) { for(int j=0;j<size;j++) { int tmp=matrix[i][j]; matrix[i][j]=matrix[size-1-i][j]; matrix[size-1-i][j]=tmp; } } for(int i=0;i<size;i++) { for(int j=i;j<size;j++) { int tmp=matrix[i][j]; matrix[i][j]=matrix[j][i]; matrix[j][i]=tmp; } } return ; }};

 

Leetcode048. Rotate Image