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: 23ms
Memory: 1752kB
Author: 2017212212174
In contest: 1273

#include<bits/stdc++.h>

using namespace std;

int p[101][101]; 


int main(){
	int n,m,k,t;
	cin>>t;
	for(int i=0;i<t;i++){
		cin>>n>>m>>k;

		for(int x=1;x<=n;x++){
			for(int y=1;y<=m;y++){
				cin>>p[x][y]; 
			} 
		} 

		if(k%4==0){
			for(int x=1;x<=n;x++){
				for(int y=1;y<=m;y++){
					cout<<p[x][y];
					if(y!=m)cout<<' ';
				} 
				cout<<endl;
			} 
		} 
		//////////////////////
		else if(k%4==1){
			for(int x=1;x<=m;x++){
				for(int y=n;y>0;y--){
					cout<<p[y][x];
					if(y!=1)cout<<' ';
				} 
				cout<<endl;
			} 
		}
		//////////////////
		else if(k%4==2){
			for(int x=n;x>0;x--){
				for(int y=m;y>0;y--){
					cout<<p[x][y];
					if(y!=1)cout<<' ';
				} 
				cout<<endl;
			} 
		}
		//////////////////
		else if(k%4==3){
			for(int x=m;x>0;x--){
				for(int y=1;y<=n;y++){
					cout<<p[y][x];
					if(y!=n)cout<<' ';
				} 
				cout<<endl;
			} 
		}
		cout<<endl; 
	} 
}