#include <conio.h>
#include <iomanip.h>
int main()
{
int P[2][3],Q[3][1],R[2][1],a,b,c;
cout<<"Sulis Setiowati\n\n";
cout << " ++++++ Operasi Perkalian Matrik ++++++\n\n";
cout<<"Orde (2x3) x Orde (3x1)\n\n";
//Masukkan matrix P
cout<<"Masukkan nilai matrik P : \n";
cout<<"------------------------- \n";
for(a=0;a<2;a++)
{
for(b=0;b<3;b++)
{
cout<<"P["<<(a+1)<<","<<(a+1)<<"]: ";
cin>>P[a][b];
}
}
//Menampilkan matrix P
cout<<"\nMatrik P : \n";;
for(a=0;a<2;a++)
{
for(b=0;b<3;b++)
{
cout<<setw(4)<<P[a][b];
}
cout<<endl;
}
cout<<endl;
//masukkan matriks Q
cout<<"Masukkan nilai matrik Q : \n";
cout<<"------------------------- \n";
for(a=0;a<3;a++)
{
for(b=0;b<1;b++)
{
cout<<"Q["<<(a+1)<<","<<(a+1)<<"]: ";
cin>>Q[a][b];
}
}
//menampilkan matrix Q
cout<<"\nMatrik Q : \n";
for(a=0;a<3;a++)
{
for(b=0;b<1;b++)
{
cout<<setw(4)<<Q[a][b];
}
cout<<endl;
}
//Operasi Perkalian Matrik
for (a=0;a<2;a++)
{
for (b=0;b<1;b++)
{
R[a][b]=0;
for (c=0;c<3;c++)
{
R[a][b]+= P[a][c]*Q[c][b];
}
}
}
//Menampilkan hasil Perkalian matrik
cout<<"\n\nHasil perkaliannya adalah....... \n\n";
for(a=0;a<2;a++)
{
for(b=0;b<1;b++)
{
cout<<setw(4)<<R[a][b];
}
cout<<endl;
}
cout<<endl;
getch();
return 0;
}
Tidak ada komentar:
Posting Komentar