_________________________________________________________________________________
#include <iostream>
#include <iomanip>
//#include <cstdlib.h>
#include <windows.h>
//using namespace std;
int main()
{
intMatA[3][3],MatB[3][3],X[3][3],P[3][3],K[3][3],a,b,c;
cout<<"MATRIKS
ORDO 3 X 3\n";
cout<<"==================\n";
cout<<"\nPenjumlahanMatriksOrdo
3*3";
cout<<"\nMasukkanMatriks A :
\n";
for(a=0;
a<3; a++)
{
for(b=0;
b<3; b++)
{
cout<<"ElemenMatrikske
"<<(a+1)<<","<<(b+1)<<" : ";
cin>>MatA[a][b];
}
}
cout<<"\nMatriks A : \n";
for(a=0; a<3; a++)
{
for(b=0; b<3; b++)
{
cout<<setw(4)<<MatA[a][b];
}
cout<<endl;
}
cout<<endl;
cout<<"MasukkanMatriks B :
\n";
for(a=0;
a<3; a++)
{
for(b=0; b<3; b++)
{
cout<<"ElemenMatrikske
"<<(a+1)<<","<<(b+1)<<" : ";
cin>>MatB[a][b];
}
}
cout<<"\nMatriks B : \n";
for(a=0;
a<3; a++)
{
for(b=0; b<3; b++)
{
cout<<setw(4)<<MatB[a][b];
}
cout<<endl;
}
for(a=0; a<3; a++)
{
for(b=0; b<3; b++)
{
X[a][b]=0;
for (c=0; c<3; c++)
{
X[a][b] += MatA[a][c] * MatB[c][b];
}
}
}
for(a=0;a<3;a++)
{
for(b=0;b<3;b++)
{
P[a][b]=0;
for(c=0;c<3;c++)
{P[a][b] =MatA[a][b] + MatB[a][b];}
}
}
for(a=0;a<3;a++)
{
for(b=0;b<3;b++)
{
K[a][b]=0;
for(c=0;c<3;c++)
{K[a][b] =MatA[a][b] - MatB[a][b];}
}
}
{
intmatrik;
cout<<"\n\nHasilPenjumlahanMatriksAdalah
: \n";
}
for(a=0;a<3;a++)
{
for(b=0;b<3;b++)
{
cout<<setw(4)<<P[a][b];
}
cout<<endl;
}
system("pause");
}
0 komentar:
Posting Komentar