class Solution {
public:
    vector<vector<int> > rotateMatrix(vector<vector<int> > mat, int n) {
        for (int i = 0; i < n; ++i) {
            reverse(mat[i].begin(), mat[i].end());
        }
        for (int i = 0; i < n; ++i) {
            for (int j = 0; i + j < n - 1; ++j) {
                swap(mat[i][j], mat[n - 1 - j][n - 1 - i]);
            }
        }
        return mat;
    }
};

思路:翻转两次。