Friday, 25 May 2012

Matrix Transpose Program

#include <cstdlib>
#include <iostream>

using namespace std;

int main()

{
int a[10][10],m,n,i,j;
cout<<"Masukkan Jumlah Baris: ";
cin>>m;
cout<<"Masukkan Jumlah kolom: ";
cin>>n;
cout<<endl<<"Elemen matriks: "<<endl;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
cout<<"masukkan elemen a: "<<i+1<<j+1<<": ";
cin>>a[i][j];
}
}
cout<<endl<<"Matriks: "<<endl<<endl;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
cout<<a[i][j]<<" ";
}
cout<<endl<<endl;
}
cout<<endl<<"Transpose Matriks: "<<endl<<endl;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
cout<<a[j][i]<<" ";
}
cout<<endl<<endl;
}
system("PAUSE");
return EXIT_SUCCESS;

}

0 comments:

Post a Comment

.

.

.

.
Design by BlogSpotDesign | Ngetik Dot Com