View Code of Problem 45

#include<iostream>
using namespace std;

int main(){
	int N;
	cin>>N;
	int k[N][N];
	for(int i=0;i<N;i++){
			for(int j=0;j<N;j++){
				cin>>k[i][j];
			}
			//cout<<"\n";
		}
	int temp;
	for(int i=0;i<N-1;i++){
		for(int j=i;j<N;j++){
			if(j!=i){
				temp=k[i][j];
				k[i][j]=k[j][i];
				k[j][i]=temp;
			}
		}
		
	}
		for(int i=0;i<N;i++){
			for(int j=0;j<N;j++){
				cout<<k[i][j];
				if(j<N){
					cout<<" ";
				}
			}
			if(i<N){
				cout<<"\n";	
			}
			
		}
	
}

Double click to view unformatted code.


Back to problem 45