Halo Bloggers,
Kali ini saya akan nge-share kode program untuk menjumlahkan 2 buah matriks bolean
Bagi yang butuh buat di pelajarin code nya, silahkan di comot aja ya gaaan :D
#define MAX 10
#include <stdbool.h>
int main(){
int i, j , k,l;
int A[k][l], B[k][l], hasil[k][l];
printf("Ukuran matriks: ");
scanf("%d %d", &i, &j);
printf("\nMatriks 1: \n");
for(k=0; k<i; k++){
for(l=0; l<j; l++){
do {
printf("Nilai elemen [%d][%d]: ", k, l);
scanf("%d", &A[k][l]);
}
while (A[k][l]!=0 && A[k][l]!=1 );
}
}
printf("\nMatriks 2: \n");
for(k=0; k<i; k++){
for(l=0; l<j; l++){
do {
printf("Nilai elemen[%d][%d]: ", k, l);
scanf("%d", &B[k][l]);
}
while (B[k][l]!=1 && B[k][l]!=0);
}
}
for(k=0; k<i; k++){
for(l=0; l<j; l++){
hasil[k][l]=A[k][l]||B[k][l];
}
}
printf("\nJadi,A+B: \n");
for(k=0; k<i; k++){
for(l=0; l<j; l++){
hasil[k][l]=A[k][l] || B[k][l];
printf("%d ", hasil[k][l]);
}
printf("\n");
}
getch();
return 0;
}
Monday, March 11, 2013
Subscribe to:
Post Comments (Atom)
Nozh_Statistik
About Me
Translate
Facebook Nozhbitha
Twitter-nozhbitha
Followers
copyright by Nozhbitha. Powered by Blogger.
Labels
- ALPRO (9)
- Buah tangan (5)
- ISENG_ISENG (1)
- Latihan alpro (30)
- Linux (1)
- Nozh Gallery (2)
- Nozhbitha (29)
- Pemrograman C++ (7)
- tentang alpro (12)
0 comments:
Post a Comment