THOUSANDS OF FREE BLOGGER TEMPLATES

Rabu, 26 Mei 2010

perkalian dua matiks

/* perkalian matriks */

#include
#define nilai_i 2
#define nilai_j 3
#define nilai_k 2
main()
{
int i,j,k;
int matrik_A[3][3],
matrik_B[3][3],
matrik_C[3][3],
clrscr();
printf("Jumlah Baris dan Kolom matrik\n");
printf("Matriks A : [2,3]\n");
printf("Matriks B : [3,2]\n");
printf("\n");
printf("Input Nilai Matrik A\n");
for(i=0;i { for(j=0;j printf("Baris ke-%d, kolom ke-%d = ",i+1,j+1);
scanf("%d",&matrik_A[i][j]); }
}
printf("\n");
printf("Input Nilai Matrik B\n");
for(j=0;j{ for(k=0;kprintf("Baris ke-%d, kolom ke-%d = ",j+1,k+1);
scanf("%d",&matrik_B[j][k]); }
}
printf("\n");
for(i=0;i {
for(k=0;k {
matrik_C[i][k] = 0;
for(j=0;j matrik_C[i][k]+=matrik_A[i][j]*matrik_B[j][k];
}
}

printf("Nilai Matrik C = A x B adalah \n");
for(i=0;i{
for(k=0;kprintf("%6d",matrik_C[i][k]);
printf("\n");
}
printf("\n");


getch();
}

0 komentar: