#include <iostream>
#include <iomanip>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main(int argc, char *argv[]) {
int i,j,hasil[3][3];
int data[3][3],data2[3][3];
//untuk menampilkan isi matrik
cout<<"Isi variabel data adalah "<<endl;
cout<<"-------------------------\n\n";
cout<<" MATRIK 1 | MATRIK 2 "<<endl;
for (i=0;i<3;i++)
{ for(j=0;j<3;j++)
{cout<<"masukkan data "<<setw(3)<<i<<" "<<j<<":"<<setw(3);
cin>>data[i][j];
cout<<"masukkan data2 "<<setw(2)<<i<<" "<<j<<":"<<setw(3);
cin>>data2[i][j];}}
for (i=0;i<3;i++)
{for(j=0;j<3;j++)
{ cout<<setw(3)<<data[i][j];}
cout<<" | ";
for(j=0;j<3;j++)
{cout<<setw(3)<<data2[i][j];}
cout<<endl;}
//untuk proses penjumlahan
cout<<"\n\n Hasil Penjumlahan kedua Matrik"<<endl;
for (i=0;i<3;i++)
{ for(j=0;j<3;j++)
{hasil[i][j]=data[i][j]+data2[i][j];
cout<<" "<<hasil[i][j]<<" ";}
cout<<endl;}
return 0;
}
Hasil Compile :
Langganan:
Posting Komentar (Atom)
0 komentar:
Posting Komentar