C++ Perkalian Matriks

Program bahasa C++ perkalian matriks dengan array yang diinputkan.

#include
#include

main()
{
int A[100][100],B[100][100],C[100][100],i,j,k,barisa,koloma,barisb,kolomb,barisc,kolomc;
printf ("QUIZ Struktur Data PERKALIAN MATRIKS\n");
printf ("NINDA NURUL RHAMADANI\n");
printf ("16416255201047\n");
printf ("IF16C\n");
printf ("\n");
printf ("=========================================\n");

//Input Nilai Ordo Matriks A
printf("Masukkan ordo matriks A\n");
printf("Jumlah baris :"); scanf ("%d", &barisa);
printf("Jumlah Kolom :"); scanf ("%d", &koloma);

printf("Masukkan nilai Matrix A berordo\n");
for (i=0; i{
for (j=0; j{
printf("A[%d,%d] = ", i, j);
scanf("%d", &A[i][j]);
printf ("\n");
}
}

//Input Nilai Ordo Matriks B
printf("Masukkan ordo matriks B\n");
printf("Jumlah baris :"); scanf ("%d", &barisb);
printf("Jumlah Kolom :"); scanf ("%d", &kolomb);

for (i=0; i{
for (j=0; j{
printf("B[%d,%d] = ", i, j);
scanf("%d", &B[i][j]);
printf ("\n");
}
}
//PERKALIAN matriks a * matriks b = matriks c
for (i=0; i{
for (j=0; j{
C[i][j]=0;
for (k=0; k{
    C[i][j]+=A[i][k]*B[k][j];
}
}
}
//Menampilkan Matrix A
printf("\nMatriks A\n");
for (i=0; i{
for (j=0; j{
printf("%5d", A[i][j]);
}
printf("\n");
}
//Menampilkan Matrix B
printf("\nMatriks B\n");
for (i=0; ifor (j=0; jprintf("%5d", B[i][j]);
}
printf("\n");
}
//Menampilkan Matrix C
printf("\nHasil Perkalian Matriks A dan B = \n");
for (i=0; ifor (j=0; j{
printf("%5d",  C[i][j]);
}
printf("\n");
}
return 0;
}


HASIL PROGRAM



Komentar

Postingan populer dari blog ini

Conceptual Data Model [CDM] dan Physical Data Model [PDM] Database

Object Oriented Database

Definisi Basis Data