Jumat, 09 Maret 2012

Transpose matrik

Nih tugas q midtest... ya program transpose matrik. Konsepnya sih pake array... cuma baris jadi kolom n kolom jadi bariss... ya tinggal di ubah aja variabel nya...

nih syntaknya..

#include <windows.h>
#include <iostream.h>

void main()
{system ("color 0a");
char jawab;
do
{system ("cls");

int a[10][10],m,n,i,j;
cout<<"\n==================================================";
cout<<"\n|| Program Transpose Matrik ||";
cout<<"\n==================================================";
cout<<"\n\nMasukkan 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 ["<<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(j=0;j<n;j++)
{
for(i=0;i<m;i++)
{
cout<<a[i][j]<<" ";
}
cout<<endl<<endl;
}

cout<<"Ingin Mengulang?[Y/T]";
cin>>jawab;}
while (jawab=='Y'||jawab=='y');
}
 n itu tadi tampilan dari baris program diatas....slamat mencoba ^_^

Tidak ada komentar:

Posting Komentar