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: 25ms
Memory: 1716kB
Author: 2018212212012
In contest: 1273

#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>

using namespace std;

int main()
{
	int t;
	cin >> t;
	while(t--){
		int i, j;
		int n, m, k;
		int a[100][100];
		int b[100][100];
		cin >> n >> m >> k;
		
		for(i=0;i<n;i++){
			for(j=0;j<m;j++){
				cin >> a[i][j];
			}
		}
		
		
		if(m==n){
		    if(k%4==1){
			    for(i=0;i<n;i++){
				    for(j=0;j<m;j++){
					    b[i][j] = a[m-j-1][i];
				    }
			    }    
		    }else if(k%4==2){
			    for(i=0;i<n;i++){
				    for(j=0;j<m;j++){
					    b[i][j] = a[n-i-1][m-j-1];
				    }
			    }
		    }else if(k%4==3){
			    for(i=0;i<n;i++){
				    for(j=0;j<m;j++){
					    b[i][j] = a[j][m-i-1];
				    }
			    }
		    }else if(k%4==0){
			    for(i=0;i<n;i++){
				    for(j=0;j<m;j++){
					    b[i][j] = a[i][j];
				    }
			    }
		    }
		    
		}else{
			if(k%4==1){
				int t;
				t = m;
				m = n;
				n = t;
			    for(i=0;i<n;i++){
				    for(j=0;j<m;j++){
					    b[i][j] = a[m-j-1][i];
				    }
			    }    
		    }else if(k%4==2){
			    for(i=0;i<n;i++){
				    for(j=0;j<m;j++){
					    b[i][j] = a[n-i-1][m-j-1];
				    }
			    }
		    }else if(k%4==3){
		    	int t;
				t = m;
				m = n;
				n = t;
			    for(i=0;i<n;i++){
				    for(j=0;j<m;j++){
					    b[i][j] = a[j][n-i-1];
				    }
			    }
		    }else if(k%4==0){
			    for(i=0;i<n;i++){
				    for(j=0;j<m;j++){
					    b[i][j] = a[i][j];
				    }
			    }
		    }
		}
		
		for(i=0;i<n;i++){
			for(j=0;j<m;j++){
				if(j!=m-1){
					cout << b[i][j] << " ";
				}if(j==m-1){
					cout << b[i][j] << endl;
				}
			}
		}
		
		cout << endl;
	}
	
	
	return 0;
}