MENGHASILKAN TRANPOSE SUATU MATRIX


1. IDENTIFIKASI MASALAH
  •   Menghasilkan tranpose suatu matrix
2. MENENTUKAN INPUT DAN OUTPUT
    input ;i, j, a, b ,o, mat [m][n]
    output :
                           dat[i][j] : matrik setelah ditranpose
3. Membuat Flowcart algoritma


 Deklarasi:
 i,j,a,b,o,mat[m][n]        :integer
Deskripsi:
write(‘Program transpose matriks C(m,n)’)
for i0 to m do then i++
for j0 to n do then j++
write(‘nilai C("<<i+1<<","<<j+1<<")’)
end for
end for
                                               
write(‘matriks diatas diilustrasikan seperti gambaran dibawah ini’)
for i0 to m do then i++
for j0 to n do then j++
write(‘mat[i][j]’)
end for
end for
om
mn
no;
write(‘Transpose matriksnya adalah seperti gambar dibawah ini\’)
for i0 to m do then i++
for j0 to n do then j++
write(‘mat[i][j]’)
end for
end for
 
4.TEST MENGGUNAKAN DATA
 
→inputin             :nilai m=2
                            Nilain n=4
                                 
→ouput               :matriks dapat di ilustrasikan seperti gambar di bawah ini
                                1 2 3 4
                                4 3 2 1
                                
                                transpose matriksnya adalah
                                1 4 3 4
                                2 9 8 0
                                8 4 2 3
 
 
5. IMPLEMENTASI C++
 
   #include <iostream>
using namespace std;
main(){ int i,j,a,b,o;
                cout<<"Program transpose matriks C(m,n)\nMasukkan nilai m : ";
                cin>>a; cout<<"masukkan nilai n : "; cin>>b;
                int mat[a][b];
                for(i=0;i<a;i++){
                                for(j=0;j<b;j++){
                                                cout<<"nilai C("<<i+1<<","<<j+1<<")=";
                                                cin>>mat[i][j];
                                }
                                cout<<endl;
                }
                system("cls");
                cout<<"matriks diatas diilustrasikan seperti gambaran dibawah ini\n\n";
                for(i=0;i<a;i++){
                                for(j=0;j<b;j++){
                                                cout<<mat[i][j]<<" ";
                                }
                                cout<<endl;
                }
                o=a; a=b; a=o;
                cout<<"\nTranspose matriksnya adalah seperti gambar dibawah ini\n\n";
                for(j=0;j<a;j++){
                                for(i=0;i<b;i++){
                                                cout<<mat[i][j]<<" ";
                                }
                                cout<<endl;
                }
}
 
6. EKSEKUSI

 

0 komentar: