View Code of Problem 45

#include<iostream>
using namespace std;
int main()
{
   int n;
   cin>>n;
   int a[n][n];
   for(int i=0;i<n;i++)
   {
   	 for(int j=0;j<n;j++)
   	   cin>>a[i][j];
   } 
   
   for(int i=0;i<n;i++)
   {
   	   for(int j=i+1;j<n;j++ )
   	   {
   	   	// swap(a[i][j],a[j][i]);  
			  int temp;
			  temp=a[i][j];
			  a[i][j]=a[j][i];
			  a[j][i]=temp; 	   	
	   }
   }
   
   for(int i=0;i<n;i++)
   {  
	 for(int j=0;j<n;j++)
	  {
	  	 cout<<a[i][j];
	  	 if(j!=n) cout<<" ";
	  }	
	  cout<<endl;
	}  
	
} 

Double click to view unformatted code.


Back to problem 45