北邮OJ 304 旋转图像
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190325224157518.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2JpbmdrdW9sdW9f,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190325224222653.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2JpbmdrdW9sdW9f,size_16,color_FFFFFF,t_70)
#include <bits/stdc++.h>
using namespace std;
int a[55][55];
int b[55][55];
int n,m;
void rotate() {
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
b[j][n-1-i]=a[i][j];
}
}
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
a[i][j]=b[i][j];
}
a[i][n]='\0';
}
swap(n,m);
}
int main(){
int T;
scanf("%d",&T);
while(T--){
scanf("%d %d",&n,&m);
for(int i=0;i<n;i++)
for(int j=0;j<m;j++)
scanf("%1d",&a[i][j]);
int angle;
scanf("%d",&angle);
angle=angle/90;
while(angle--){
rotate();
}
for(int i=0;i<n;i++){
for(int j=0;j<m;j++)
printf("%d",a[i][j]);
printf("\n");
}}
}