Transport -Data Structure
#include<iostream>
using namespace std;
int main()
{
int arr[50][50], result[50][50];
int r,c;
cout<<"Enter the number of row: ";
cin>>r;
cout<<"Enter the number of column: ";
cin>>c;
cout<<"Enter elements of Matrix: ";
for(int i=0; i<r; i++)
for(int j=0; j<c; j++)
cin>>arr[i][j];
cout<<"Your Matrix is :"<<endl;
for(int i=0; i<r; i++)
{
for(int j=0; j<c; j++)
cout<<arr[i][j]<<" ";
cout<<endl;
}
for(int i=0; i<r; i++)
for(int j=0; j<c; j++)
result[j][i] = arr[i][j];
cout<<"After Transpose :"<<endl;
for(int i=0; i<c; i++)
{
for(int j=0; j<r; j++)
cout<<result[i][j]<<" ";
cout<<endl;
}
}
0 Comments