:::: MENU ::::
  • life isn't about getting and taking , it's about giving and being

  • Identify your passion then design your future

Selasa, 24 Mei 2016


1.Identifikasi permasalahan
   - Cara Perkalian matriks dengan vektor

2.Mengidentifikasi Input dan Output
   -Input matrik = 1 2
                             3 4
              vektor = 1
                            2

   -Output = 1 2 2 4
                    3 6 4 8

3.Analisis
   -Syarat perkalian matriks dan vektor adalah memiliki jumlah baris dan kolom yang sama

4.Algoritma
Int matriks(int arr[50][50], int baris,int kolom)
Deklarasi:
I,j,x[kolom],y,N :integer

Dekskrpsi:
For(i=1;i<=baris;i++)
For(j=1;j<=kolom;j++)
For(y=1;y<=kolom;y++)
N=arr[i][j]*x[y]
 Write N
End for
End for
End for
End

5.C++
 #include <iostream>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

using namespace std;
int matriks(int array[50][50], int kolom, int baris){
    int i,j;
    for(i=1;i<=baris;i++){
    for(j=1;j<=kolom;j++){
    cout<<"Baris ke- "<<i<<" kolom ke- "<<j<<"  = ";cin>>array[i][j];cout<<endl;
    }
}

cout<<"matriks\n";
    for(i=1;i<=baris;i++){
        for(j=1;j<=kolom;j++){
            cout<<array[i][j]<<" ";
            }

cout<<endl;

}

int x[kolom],n;
cout<<"Variable ";cin>>x[kolom];

for(int y=1;y<=kolom;y++){
    cout<<"data ke- "<<y<<" = ";cin>>x[y];cout<<endl;
}

cout<<"vektor\n";
for(int y=1;y<=kolom;y++){
    cout<<x[y]<<endl;
}
cout<<"perkalian matriks dan vektor"<<endl;
for(int i=1;i<=baris;i++){
    for(int j=1;j<=kolom;j++){
        for(int y=1;y<=kolom;y++){
            n=array[i][j]*x[y];
            cout<<n<<" ";
        }
    }

cout<<endl;

}
}


int main(int argc, char** argv) {
int array[50][50],a,b;

cout<<"kolom : ";
cin>>a;
cout<<endl;
cout<<"baris : ";
cin>>b;
cout<<endl;
matriks(array,a,b);
return 0;
}

6.Debugging




0 komentar:

Posting Komentar

Thank's udah mampir guys