#include <conio.h>
#include <iostream.h>
void main(){
int mat1[2][2],mat2[2][2],mat3[2][2],mat4[2][2];
for(int a=1;a<=2;a++){
cout<<"Matriks "<<a<<" : "<<endl;
for(int x=0;x<2;x++){
for(int y=0;y<2;y++){
cout<<"Input Elemen ["<<(x+1)<<"],["<<(y+1)<<"] : ";
a==1?cin>>mat1[x][y]:cin>>mat2[x][y];
}
cout<<endl;
}
cout<<endl;
}
//tampil
for(int a=1;a<=2;a++){
cout<<"Matriks "<<a<<" : "<<endl;
for(int x=0;x<2;x++){
for(int y=0;y<2;y++){
a==1?cout<<mat1[x][y]<<"\t":cout<<mat2[x][y]<<"\t";
mat3[x][y]=mat1[x][y]+mat2[x][y];
mat4[x][y]=mat1[x][y]-mat2[x][y];
}
cout<<endl;
}
cout<<endl;
}
for(int a=1;a<=2;a++){
a==1?cout<<"Hasil Penjumlahan :"<<endl:cout<<"\nHasil Pengurangan :"<<endl;
for(int x=0;x<2;x++){
for(int y=0;y<2;y++){
a==1?cout<<mat3[x][y]<<"\t":cout<<mat4[x][y]<<"\t";
}
cout<<endl;
}
cout<<endl;
}
getch();
}
Tidak ada komentar:
Posting Komentar