Matriks 2
Matriks
#include<iostream>
using namespace std;
//kamus
int a[3][4] = {2,3,4,1,2,4,1,6,8,1,1,7};
int b[3][4] = {4,4,9,1,8,2,1,1,1,5,1,3};
int c[3][4] = {4,7,9,1,1,7,3,1,3,3,1,2};
int x,y,d;
//deskripsi
int main()
{
cout << "Penjumlahan Pengurangan Matriks Ordo 3x4" << endl;
cout << "MatD = (MatA+MatB)-(MatA+MatC)" << endl << endl;
cout << "MatA" << endl;
x=0;
do
{
y=0;
do
{
cout << a[x][y] << " ";
y=y+1;
}while(y<4);
x=x+1;
cout << endl;
}while(x<3);
cout << "MatB" << endl;
x=0;
do
{
y=0;
do
{
cout << b[x][y] << " ";
y=y+1;
}while(y<4);
x=x+1;
cout << endl;
}while(x<3);
cout << "MatC" << endl;
x=0;
do
{
y=0;
do
{
cout << c[x][y] << " ";
y=y+1;
}while(y<4);
x=x+1;
cout << endl;
}while(x<3);
cout << "MatD" << endl;
x=0;
do
{
y=0;
do
{
d = (a[x][y]+b[x][y])-(a[x][y]+c[x][y]);
cout << d << " ";
y=y+1;
}while(y<4);
x=x+1;
cout << endl;
}while(x<3);
return 0;
}
Komentar
Posting Komentar