Result: Accepted
Time: 5ms
Memory: 1184kB
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#define ll long long
using namespace std;
const int maxn = 110;
const int inf = 0x3f3f3f3f;
int n, m, k;
int a[maxn][maxn];
int b[maxn][maxn];
int main()
{
int t;
scanf("%d", &t);
while (t--)
{
scanf("%d %d %d", &n, &m, &k);
for (int i = 1; i <= n; ++i)
{
for (int j = 1; j <= m; ++j)
{
scanf("%d", &a[i][j]);
}
}
if (k % 4 == 0)
{
for (int i = 1; i <= n; ++i)
{
for (int j = 1; j <= m; ++j)
{
if (j != 1)printf(" ");
printf("%d", a[i][j]);
}
printf("\n");
}
}
else if (k % 4 == 1)
{
for (int i = 1; i <= n; ++i)
{
for (int j = 1; j <= m; ++j)
{
b[j][n + 1 - i] = a[i][j];
}
}
for (int i = 1; i <= m; ++i)
{
for (int j = 1; j <= n; ++j)
{
if (j != 1)printf(" ");
printf("%d", b[i][j]);
}
printf("\n");
}
}
else if (k % 4 == 2)
{
for (int i = n; i >= 1; --i)
{
for (int j = m; j >= 1; --j)
{
if (j != m)printf(" ");
printf("%d", a[i][j]);
}
printf("\n");
}
}
else if (k % 4 == 3)
{
for (int i = 1; i <= n; ++i)
{
for (int j = 1; j <= m; ++j)
{
b[m+1-j][i] = a[i][j];
}
}
for (int i = 1; i <= m; ++i)
{
for (int j = 1; j <= n; ++j)
{
if (j != 1)printf(" ");
printf("%d", b[i][j]);
}
printf("\n");
}
}
printf("\n");
}
return 0;
}