Rumus penambahan Matrik ini
C[i] [j] = A[i] [j] + B[i] [j]
#include "iostream.h"
void main(){
int a[3][3], b[3][3], c[3][3] ;
int i, j ;
cout << "Memproses Penambahan Matrik \n --------------------------------------------\n" ;
for (i=0 ; i <=2 ; i++)
for (j=0 ; j<=2 ; j++) {
cout << " Matrik A[" << i << " , " << j << "]: " ; cin>> a[i][j];
}
for (i=0 ; i <=2 ; i++)
for (j=0 ; j<=2 ; j++) {
cout << " Matrik B[" << i << " , " << j << "]: " ; cin>> b[i][j];
}
for (i=0 ; i <=2 ; i++)
for (j=0 ; j<=2 ; j++)
c[i][j] = a[i][j] + b[i][j] ;
for (i=0 ; i <=2 ; i++)
for (j=0 ; j<=2 ; j++) {
cout << "\n Matrik C[" << i << " , " << j << "]: " << c[i][j] ;
}
}
Bagaimana mudah bukan?
0 comments:
Post a Comment
Terima kasih apabila sudah memberikan komentar yang baik dan sopan :)