#include <vector> class Solution { public: //一个简单的思路 vector<vector<int> > rotateMatrix(vector<vector<int> >& mat, int n) { // write code here vector<vector<int>> ans(n, vector<int>(n)); vector<int> temp(n*n); //类似于打点的思路 int k = 0; for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ temp[k] = mat[i][j]; k++; } } k = 0; for(int j = n-1; j >= 0; j-- ){ for(int i = 0; i < n; i++){ ans[i][j] = temp[k++]; } } return ans; } };