Monday, April 16, 2012
PENJUMLAHAN MATRIKS TANPA INPUT
#include <iostream.h>
#include <conio.h>
void main ()
{
int a[2][2] = {1,2,3,4};
int b[2][2] = {5,6,7,8};
int hasil[2][2];
cout<<"Matriks 1"<<"\t"<<"Matriks 2\n\n";
cout<< a[0][0]<<"\t"<< a[0][1]<<"\t";
cout<< b[0][0]<<"\t"<< b[0][1]<<"\t\n";
cout<<"\t +\n";
cout<< a[1][0]<<"\t"<< a[1][1]<<"\t";
cout<< b[1][0]<<"\t"<< b[1][1]<<"\t\n";
hasil[0][0]=a[0][0]+b[0][0];
hasil[0][1]=a[0][1]+b[0][1];
hasil[1][0]=a[1][0]+b[1][0];
hasil[1][1]=a[1][1]+b[1][1];
cout<<"\n\nMatriks Hasil\n\n";
cout<<hasil[0][0]<<"\t";
cout<<hasil[0][1]<<"\t\n\n";
cout<<hasil[1][0]<<"\t";
cout<<hasil[1][1]<<"\t\n";
}
Labels:
Algoritma dan Pemrograman
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment