Algoritma dengan pseuducode
1. Masukkan ordo matrik(n)
2. Input matrik di dalam array [0][0] sampai dengan array[n][n]
3. ditampilkan matrik tersebut
4. menukar matrik[i][j] menjadi matrik[j][i]
5. ditampilkan hasil matrik tranpose
Deklarasi :
a[10][10] : int
m,n,i,j : int
Deskripsi :
Baca (m)
Baca (n)
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
Tulis a[i][j]
Transpose :
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
Transpose a[j][i]
Implementasi dalam bahasa C++
#include <cstdlib> #include <iostream> using namespace std; int main(int argc, char *argv[]) { int a[10][10],m,n,i,j; cout<<"Masukkan Jumlah Baris: "; cin>>m; cout<<"Masukkan Jumlah kolom: "; cin>>n; cout<<endl<<"Enter elements of matrix: "<<endl; for(i=0;i<m;i++) { for(j=0;j<n;j++) { cout<<"Enter element 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 Response for the "Transpose Matrix Program"
Post a Comment