Program :
#include <iostream.h>
#include <conio.h>
main (){
int
matrikA[2][3],matrikB[3][3],has[2][3];
int i,j;
cout<<"Program
Perkalian Matrik 2X3 dengan 3X3\n";
cout<<"\nMasukkan
matrik A\n";
cout<<"=====================================\n";
for(i=0;i<2;i++){
for(j=0;j<3;j++){
cout<<"Input baris "<<i+1<<" kolom
"<<j+1<<" : ";
cin>>matrikA[i][j];
}
cout<<endl;
}
for(i=0;i<2;i++){
for(j=0;j<3;j++){
cout<<matrikA[i][j]<<"\t";
}
cout<<endl;
}
cout<<"\nMasukkan
matrik B\n";
cout<<"=====================================\n";
for(i=0;i<3;i++){
for(j=0;j<3;j++){
cout<<"Input baris "<<i+1<<" kolom
"<<j+1<<" : ";
cin>>matrikB[i][j];
}
cout<<endl;
}
cout<<endl;
for(i=0;i<3;i++){
for(j=0;j<3;j++){
cout<<matrikB[i][j]<<"\t";
}
cout<<endl;
}
for(i=0;i<2;i++)
{
for(j=0;j<3;j++)
{
has[i][j]=matrikA[i][0]*matrikB[0][j]+matrikA[i][1]*matrikB[1][j]+matrikA[i][2]*matrikB[2][j];
}
}
cout<<endl;
cout<<"\nHasil :";
for(i=0;i<2;i++){
for(j=0;j<3;j++){
cout<<"\t\t"<<has[i][j];
}
cout<<endl;
}
getch ();}
Contoh hasilnya :
0 komentar:
Posting Komentar