Menyelesaikan Matriks C++

Bagi teman-teman yang bermasalah dengan matriks menggunakan C++, kita simak pembahasan ny :


#include <iostream>
#include <windows.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
int a[2][3];
for(int i=0;i<2;i++){
for(int j=0;j<3;j++){
cout<<" data matriks A baris ke "<<i<<"kolom ke "<<j<<" : ";
cin>>a[i][j];
}
}
cout<<"\n\n matrik A \n "<<endl;
for(int i=0;i<2;i++){
for(int j=0;j<3;j++){
cout<<a[i][j]<<" ";
}
cout<<endl;
}
int b[2][3];
for(int i=0;i<2;i++){
for(int j=0;j<3;j++){
cout<<" data matriks B baris ke "<<i<<"kolom ke "<<j<<" : ";
cin>>b[i][j];
}
}
cout<<"\n\n matrik B \n"<<endl;
for(int i=0;i<2;i++){
for(int j=0;j<3;j++){
cout<<b[i][j]<<" ";
}
cout<<endl;
}
cout<<"penjumlahan matrik A dan B \n"<<a[0][0]+b[0][0]<<" "<<a[0][1]+b[0][1]<<" "<<a[0][2]+b[0][2]<<endl<<a[1][0]+b[1][0]<<" "<<a[1][1]+b[1][1]<<" "<<a[1][2]+b[1][2];
cout<<"pengurangan matrik A dan B \n"<<a[0][0]-b[0][0]<<" "<<a[0][1]-b[0][1]<<" "<<a[0][2]-b[0][2]<<endl<<a[1][0]-b[1][0]<<" "<<a[1][1]-b[1][1]<<" "<<a[1][2]-b[1][2];
return 0;
}

output :




Share this

Related Posts

Previous
Next Post »

3 komentar

komentar
7 March 2016 at 05:53 delete

Eih keren gan ... nambah pengetahuan ...

Reply
avatar
7 March 2016 at 05:57 delete

sama-sama gan kunjungi aja website ini kalo ada masalah dengan C++

Reply
avatar
12 March 2016 at 20:55 delete

tolong dong om, source code nya dirapihin biar enak bacanya.
thx

Reply
avatar