1.6数组 像素翻转

 1 class Transform {
 2 public:
 3     vector<vector<int> > transformImage(vector<vector<int> > mat, int n)
 4     {
 5         for(int layer=0;layer<n/2;++layer)
 6         {
 7             int first=layer;
 8             int last=n-1-layer;
 9             for(int i=first;i<last;++i)
10             {
11                 int offset=i-first;
12                 //存储上边
13                 int top=mat[first][i];
14                 //左到上
15                 mat[first][i]=mat[last-offset][first];
16                 //下到左
17                 mat[last-offset][first]=mat[last][last-offset];
18                 //右到下
19                 mat[last][last-offset]=mat[i][last];
20                 //上到右
21                 mat[i][last]=top;
22             }
23         }
24         return mat;
25     }
26 };
原文地址:https://www.cnblogs.com/hslzju/p/5703962.html