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