Result: Accepted
Time: 6ms
Memory: 1092kB
#include<stdio.h>
int main(){
int t,n,m,k,i,j,a,b;
int A[101][101];
scanf("%d",&t);
while(t--){
scanf("%d %d %d",&n,&m,&k);
for(i=1;i<=n;++i){
for(j=1;j<=m;++j){
scanf("%d",&b);
A[i][j]=b;
}
}
a=k%4;
if(a==0){
for(i=1;i<=n;++i){
for(j=1;j<=m;++j){
printf("%d ",A[i][j]);
}
printf("\n");
}
printf("\n");
}
else if(a==1){
for(i=1;i<=m;++i){
for(j=n;j>0;--j){
printf("%d ",A[j][i]);
}
printf("\n");
}
printf("\n");
}
else if(a==2){
for(i=n;i>0;--i){
for(j=m;j>0;--j){
printf("%d ",A[i][j]);
}
printf("\n");
}
printf("\n");
}
else if(a==3){
for(i=m;i>0;--i){
for(j=1;j<=n;++j){
printf("%d ",A[j][i]);
}
printf("\n");
}
printf("\n");
}
}
return 0;
}