Result: Accepted
Time: 11ms
Memory: 1712kB
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
int i,j,k,t,n,m,a[100][100];
cin >> t;
while(t--)
{
cin >> n >> m >> k;
for(i=0;i<n;i++)
for (j=0;j<m;j++)
cin >> a[i][j];
switch(k%4)
{
case(1):
for(j=0;j<m;j++)
for (i=n-1;i>=0;i--)
printf("%d%c",a[i][j]," \n"[i==0]);
cout << "\n";
break;
case(2):
for(i=n-1;i>=0;i--)
for (j=m-1;j>=0;j--)
printf("%d%c",a[i][j]," \n"[j==0]);
cout << "\n";
break;
case(3):
for(j=m-1;j>=0;j--)
for (i=0;i<n;i++)
printf("%d%c",a[i][j]," \n"[i==n-1]);
cout << "\n";
break;
case(0):
for(i=0;i<n;i++)
for (j=0;j<m;j++)
printf("%d%c",a[i][j]," \n"[j==m-1]);
cout << "\n";
break;
}
}
}