//PERKALIAN MATRIK
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int matrixA[3][3];
int matrixB[3][3];
int matrixC[3][3];
int i,j;
//matrix A :
cout<<"\nINPUTAN MATRIX A :"<<"\n";
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
cout<<"Masukkan angka pada baris ke "<<i<<" kolom ke "<<j<<" : ";
cin>>matrixA[i][j];
}
cout<<endl;
}
//matrix B :
cout<<"\nINPUTAN MATRIX B :"<<"\n";
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
cout<<"Masukkan angka pada baris ke "<<i<<" kolom ke "<<j<<" : ";
cin>>matrixB[i][j];
}
cout<<endl;
}
cout<<"\nOUTPUT MATRIX A :"<<"\n";
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
cout<<matrixA[i][j]<<" ";
}
cout<<endl;
}
cout<<"\nOUTPUT MATRIX B :"<<"\n";
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
cout<<matrixB[i][j]<<" ";
}
cout<<endl;
}
cout<<"\nPerkalian Matrix A X B :"<<"\n";
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
matrixC[i][j] = ((matrixA[i][0] * matrixB[0][j]) + (matrixA[i][1] * matrixB[1][j]) + (matrixA[i][2] * matrixB[2][j]));
}
cout<<endl;
}
// Output hasil perkalian matriks
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
cout<<matrixC[i][j]<<" ";
}
cout<<endl;
}
getch();
}
setelah kalian coba program diatas (F7), kemudian di RUN (F5)..akan didapatkan hasil
sebegai berikut...tampilannya..
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int matrixA[3][3];
int matrixB[3][3];
int matrixC[3][3];
int i,j;
//matrix A :
cout<<"\nINPUTAN MATRIX A :"<<"\n";
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
cout<<"Masukkan angka pada baris ke "<<i<<" kolom ke "<<j<<" : ";
cin>>matrixA[i][j];
}
cout<<endl;
}
//matrix B :
cout<<"\nINPUTAN MATRIX B :"<<"\n";
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
cout<<"Masukkan angka pada baris ke "<<i<<" kolom ke "<<j<<" : ";
cin>>matrixB[i][j];
}
cout<<endl;
}
cout<<"\nOUTPUT MATRIX A :"<<"\n";
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
cout<<matrixA[i][j]<<" ";
}
cout<<endl;
}
cout<<"\nOUTPUT MATRIX B :"<<"\n";
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
cout<<matrixB[i][j]<<" ";
}
cout<<endl;
}
cout<<"\nPerkalian Matrix A X B :"<<"\n";
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
matrixC[i][j] = ((matrixA[i][0] * matrixB[0][j]) + (matrixA[i][1] * matrixB[1][j]) + (matrixA[i][2] * matrixB[2][j]));
}
cout<<endl;
}
// Output hasil perkalian matriks
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
cout<<matrixC[i][j]<<" ";
}
cout<<endl;
}
getch();
}
setelah kalian coba program diatas (F7), kemudian di RUN (F5)..akan didapatkan hasil
sebegai berikut...tampilannya..
Tidak ada komentar:
Posting Komentar