OJ-Problems-Source/LeetCode-CN/48_旋转图像.md
2018-06-24 12:42:12 +08:00

560 B

48. 旋转图像@2018/06/24

jzf

  • 4ms
class Solution {
public:
    void rotate(vector<vector<int>>& matrix) {
        
        int tmp;
        for(size_t i=0; i<matrix.size();i++)
        {
            for(size_t j=i+1;j<matrix.size();j++)
            {
                
                tmp =matrix[i][j];
                matrix[i][j] =matrix[j][i];
                matrix[j][i] =tmp;
            }
        }
        for(size_t i =0;i<matrix.size();i++)
        {
            reverse(matrix[i].begin(),matrix[i].end());
        }
    }
};