View Code of Problem 45

#include<iostream>
#include<map>
#include<cmath>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		int ans[22][22]={0};
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				scanf("%d",&ans[i][j]);
			}
		}
		
		for(int i=0;i<n;i++){
			for(int j=1;j<n;j++){
				int temp;
				temp=ans[i][j];
				ans[i][j]=ans[j][i];
				ans[j][i]=temp;
			}
		}
		
		
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				printf("%d",ans[i][j]);
				if(j<n-1){
					printf(" ");
				}
			}
			cout<<endl;
		}
		
		
	}
	
	
	
	
	
	
	
	
	
	
	return 0;
}

Double click to view unformatted code.


Back to problem 45