Mengerti masalah.
Mengalikan matrik (3x2) dengan vektor (3x1).
Mengalikan matrik (3x2) dengan vektor (3x1).
Menentukan input dan output.
Input: A [2,3]={4,2,1,0,1,3}.
B [3,1]={1,1,2}.
Input: A [2,3]={4,2,1,0,1,3}.
B [3,1]={1,1,2}.
Output: C = |8|
|7|
Membuat flowchart/ Algoritma.
Prosedur perkalian matriks
( input output i,j,A,B,C).
# Deklarasi
i,j = integer
i,j = integer
# Deskripsi
for i - 1 to 2 do
for j - 1 to 3 do
([i,j]=([i,j]+a[i,j]*b[i,j])
end
end
for i - 1 to 2 do
for j - 1 to 3 do
([i,j]=([i,j]+a[i,j]*b[i,j])
end
end
4. DevC++.
#include
<iostream>
using namespace
std;
void perkalian(int A [2][3],int B[3],int C[2]){
cout<<"Matrik: "<<endl;
for(int i=0;i<2;i++){
for(int j=0;j<3;j++){
C[i]=C[i]+(A[i][j]*B[j]);
}
}
}
}
void matrik(int C[][3]){
for(int i=0;i<2;i++){
for(int j=0;j<3;j++){
cout<<C[i][j]<<"
"<<endl;
}
}
}
}
void vektor(int B[]){
void vektor(int B[]){
cout<<"Vektor: "<<endl;
for(int i=0;i<3;i++){
for(int i=0;i<3;i++){
cout<<B[i]<<endl;
}
}
}
void hasil(int C[]){
cout<<"Hasul perkalian : "<<endl;
for(int i=0;i<2;i++){
cout<<C[i]<<endl; }
}
int main(int
argc, char** argv) {
int A [2][3]={4,2,1,0,1,3}, B[3]={1,1,2}, C[2]={8,7};
perkalian(A,B,C);
matrik(A);
vektor(B);
hasil(C);
return 0;
}
}
5. Menguji Coba Data.
6. Test Menggunakan
data.
0 komentar:
Posting Komentar