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