#include <iostream>
#include <stdlib.h>
using namespace std;
int main(){
int i, j, k, baris = 3, kolom = 3, matriks1[4][4], matriks2[4][4], m2_transpose[4][4], hasil_kali[4][4], hasil_akhir[4][4];
cout<<"\t\t\tProgram Penghitungan Matriks ordo 3x3"<<endl;
cout<<"Matriks A\n";
for(i = 1;i <= baris; i++)
{
for(j = 1;j <= kolom; j++)
{
cout<<"Masukan Nilai Matriks A Baris ke-"<<i<<" Kolom ke-"<<j<<" : ";
cin>>matriks1[i][j];
}
}
cout<<"\n\nMatriks B\n";
for(i = 1;i <= baris; i++)
{
for(j = 1;j <= kolom; j++)
{
cout<<"Masukan Nilai Matriks B Baris ke-"<<i<<" Kolom ke-"<<j<<" : ";
cin>>matriks2[i][j];
}
}
for(i = 1;i <= baris; i++)
{
for(j = 1;j <= kolom; j++)
m2_transpose[j][i] = matriks2[i][j];
}
system("cls");
cout<<"Matriks A\n\n";
for(i = 1;i <= baris; i++)
{
for(j = 1;j <= kolom; j++)
cout<<matriks1[i][j]<<" ";
cout<<"\n";
}
cout<<"\n\nMatriks B\n\n";
for(i = 1;i <= baris; i++)
{
for(j = 1;j <= kolom; j++)
cout<<matriks2[i][j]<<" ";
cout<<"\n";
}
cout<<"\n\nMatriks B[Transpose]\n\n";
for(i = 1;i <= baris; i++)
{
for(j = 1;j <= kolom; j++)
cout<<m2_transpose[i][j]<<" ";
cout<<"\n";
}
for(i = 1;i <= baris; i++)
{
for(j = 1;j <= kolom; j++)
{
int tamp = 0;
for(k = 1; k <= baris; k++)
tamp = tamp + matriks1[i][k] * matriks2[k][j];
hasil_kali[i][j] = tamp;
}
}
for(i = 1;i <= baris; i++)
{
for(j = 1;j <= kolom; j++)
hasil_akhir[i][j] = hasil_kali[i][j] - m2_transpose[i][j];
}
cout<<"\n\nA * B - B[Transpose] Maka Hasilnya Adalah Sebagai Berikut :\n\n";
for(i = 1;i <= baris; i++)
{
for(j = 1;j <= kolom; j++)
cout<<hasil_akhir[i][j]<<" ";
cout<<"\n";
}
cout<<"\nCreate By YOGA FIRZA SABBIHISMA";
return 0;
}
#include <stdlib.h>
using namespace std;
int main(){
int i, j, k, baris = 3, kolom = 3, matriks1[4][4], matriks2[4][4], m2_transpose[4][4], hasil_kali[4][4], hasil_akhir[4][4];
cout<<"\t\t\tProgram Penghitungan Matriks ordo 3x3"<<endl;
cout<<"Matriks A\n";
for(i = 1;i <= baris; i++)
{
for(j = 1;j <= kolom; j++)
{
cout<<"Masukan Nilai Matriks A Baris ke-"<<i<<" Kolom ke-"<<j<<" : ";
cin>>matriks1[i][j];
}
}
cout<<"\n\nMatriks B\n";
for(i = 1;i <= baris; i++)
{
for(j = 1;j <= kolom; j++)
{
cout<<"Masukan Nilai Matriks B Baris ke-"<<i<<" Kolom ke-"<<j<<" : ";
cin>>matriks2[i][j];
}
}
for(i = 1;i <= baris; i++)
{
for(j = 1;j <= kolom; j++)
m2_transpose[j][i] = matriks2[i][j];
}
system("cls");
cout<<"Matriks A\n\n";
for(i = 1;i <= baris; i++)
{
for(j = 1;j <= kolom; j++)
cout<<matriks1[i][j]<<" ";
cout<<"\n";
}
cout<<"\n\nMatriks B\n\n";
for(i = 1;i <= baris; i++)
{
for(j = 1;j <= kolom; j++)
cout<<matriks2[i][j]<<" ";
cout<<"\n";
}
cout<<"\n\nMatriks B[Transpose]\n\n";
for(i = 1;i <= baris; i++)
{
for(j = 1;j <= kolom; j++)
cout<<m2_transpose[i][j]<<" ";
cout<<"\n";
}
for(i = 1;i <= baris; i++)
{
for(j = 1;j <= kolom; j++)
{
int tamp = 0;
for(k = 1; k <= baris; k++)
tamp = tamp + matriks1[i][k] * matriks2[k][j];
hasil_kali[i][j] = tamp;
}
}
for(i = 1;i <= baris; i++)
{
for(j = 1;j <= kolom; j++)
hasil_akhir[i][j] = hasil_kali[i][j] - m2_transpose[i][j];
}
cout<<"\n\nA * B - B[Transpose] Maka Hasilnya Adalah Sebagai Berikut :\n\n";
for(i = 1;i <= baris; i++)
{
for(j = 1;j <= kolom; j++)
cout<<hasil_akhir[i][j]<<" ";
cout<<"\n";
}
cout<<"\nCreate By YOGA FIRZA SABBIHISMA";
return 0;
}