Result: Accepted
Time: 29ms
Memory: 1836kB
#include <cstdio>
#include <iostream>
using namespace std;
int n,m,t,i,j,k,a[125][125],b[125][125],temp;
int main()
{
cin>>t;
while(t--){
cin>>n>>m>>k;
for(i=0;i<n;++i){
for(j=0;j<m;++j){
cin>>a[i][j];
}
}
k%=4;
while(k--)
{
for(i=n-1;i>=0;i--){
for(j=0;j<m;++j){
b[j][n-i-1]=a[i][j];
}
}
temp=n;
n=m;
m=temp;
for(i=0;i<n;++i){
for(j=0;j<m;++j){
a[i][j]=b[i][j];
}
}
}
for(i=0;i<n;++i){
for(j=0;j<m-1;++j)
cout<<a[i][j]<<" ";
cout<<a[i][m-1]<<endl;
}
cout<<endl;
}
return 0;
}