Oleh :
Agus Saputra (D1041141049)
Muhammad Furqan (D1041141065)
Muhammad Rafi'i (D1041141009)
Algoritma Pengurangan dan Transpose Matrik Ordo 2x2
Deklarasi
Deklarasi
Matriks A[2][2]
Matriks B[2][2]
Matriks C[2][2]
Matriks
TransC[2][2]
For i←1 to 2 do
begin
For j←1 to 2 do
begin
Matriks A[i][j] ← Masukkan Nilai
[i][j]
end
end
for i←1 to 2 do
begin
for j←1 to 2 do
begin
Matriks B[i][j] ← Masukkan Nilai
[i][j]
end
end
Write Matriks A –
Matrisks B
for i←1 to 2 do
begin
for j←1 to 2 do
begin
Matriks C[i][j] ← Matriks A[i][j] –
Matriks B[i][j]
Write Matriks C[i][j]
end
end
write transpose
Matriks A – Matriks B
for i←1 to 2 do
begin
for j←1 to 2 do
begin
Matriks TransC[j][i] ← Matriks
C[i][j]
Write Matriks C[j][i]
end
end
Program Pengurangan dan Transpose Matrik Ordo 2x2 menggunakan bahasa C++
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int A[2][2];
int B[2][2];
int C[2][2];
int TransC[2][2];
cout<<"Program Pengurangan Pada
Matriks ordo 2x2"<<endl;
for(int i=0; i<2; i++)
{
for(int j=0; j<2; j++)
{
cout<<"Masukkan Matriks
A ["<<i<<"] ["<<j<<"] :
";
cin>>A[i][j];
}
}
cout<<endl;
for(int i=0; i<2; i++)
{
for(int j=0; j<2; j++)
{
cout<<"Masukkan Matriks
B ["<<i<<"] ["<<j<<"] :
";
cin>>B[i][j];
}
}
cout<<endl;
cout<<"Matriks A - Matriks B
:"<<endl;
for(int i=0; i<2; i++)
{
for(int j=0; j<2; j++)
{
C[i][j] = A[i][j]-B[i][j];
cout<<setw(3)<<C[i][j];
}
}
cout<<endl;
cout<<"Transpose Matriks C :"<<endl;
for(int i=0; i<2; i++)
{
for(int j=0; j<2; j++)
{
TransC[j][i] = C[i][j];
cout<<setw(3)<<C[j][i];
}
cout<<endl;
}
return 0;
}
No comments:
Post a Comment