Start: Jun, 26, 2019 08:30:00
2019年度暑期短学期第一天
End: Jun, 26, 2019 11:30:00
Time elapsed:
Time remaining:

Problem_ID: A
Result: Accepted
Time: 6ms
Memory: 1128kB
Author: 2018212212208
In contest: 1273

#include<stdio.h>
int main(void){
	int t,m,n,a[200][200],k,i,j,p,q,r,s;
	scanf("%d",&t);
	while(t--){
		scanf("%d %d %d",&n,&m,&k);
		for(i=0;i<n;i++){
			for(j=0;j<m;j++){
				scanf("%d",&a[i][j]);
			}
		}
		if(n!=m&&(k%4==1||k%4==3)){
			for(r=0;r<m;r++){
				for(s=0;s<n;s++){
					if(k%4==1)
						printf("%d",a[n-1-s][r]);
					if(k%4==3)
						printf("%d",a[s][m-1-r]);
					if(s<n-1)
						printf(" ");
				}
				printf("\n");
			}
			printf("\n");
		}
		else{
			for(p=0;p<n;p++){
				for(q=0;q<m;q++){
					if(k%4==0)
						printf("%d",a[p][q]);
					if(k%4==1)
					    printf("%d" ,a[n-q-1][p]);
				    if(k%4==2)
					    printf("%d",a[n-p-1][m-q-1]);
				    if(k%4==3)
					    printf("%d" ,a[q][m-p-1]);
				    if(q<m-1)
					 printf(" ");
				}
				printf("\n");
			}
			printf("\n");
		}
	}
}