Program Perkalian Matrik 2x3 dikalikan 3x3 - Larik / Array C/C++
Praktikum Larik / Array C/C++
Hasil running
#include <stdio.h> #include <conio.h> int i, x; int matriks_A[2][3], matriks_B[3][3], matriks_hasil[2][3]; int main () { printf ("Perkalian Matriks 2x3 dengan Matriks 3x3 \n\n"); { printf ("\n%%%%%%%%%% Pengisian Matriks A %%%%%%%%%%\n"); for (i = 0; i < 2; i++) { for (x = 0; x < 3; x++) { printf ("Masukan baris ke %d kolom ke %d : ",i+1, x+1); scanf ("%d",&matriks_A[i][x]); } } printf ("\nMatriks A :\n"); for (i = 0; i < 2; i++) { for (x = 0; x < 3; x++) { printf ("%d ",matriks_A[i][x]); } printf ("\n"); } printf ("\n"); printf ("\n%%%%%%%%%% Pengisian Matriks B %%%%%%%%%%\n"); for (i = 0; i < 3; i++) { for (x = 0; x < 3; x++) { printf ("Masukan baris ke %d kolom ke %d : ", i+1, x+1); scanf ("%d",&matriks_B[i][x]); } } printf ("\nMatriks B : \n"); for (i = 0; i < 3; i++) { for (x = 0; x < 3; x++) { printf ("%d ",matriks_B[i][x]); } printf ("\n"); } printf ("\n"); printf ("======== Hasil Perkalian A x B ========\n"); printf ("Matriks A x Matriks B : \n"); for (i = 0; i < 2; i++) { for (x = 0; x < 3; x++) { matriks_hasil[i][x] = matriks_A[i][0] * matriks_B[0][x] + matriks_A[i][1] * matriks_B[1][x] + matriks_A[i][2] * matriks_B[2][x]; printf ("\t%d", matriks_hasil[i][x]); } printf ("\n"); } } }
Hasil running
transpose nya dong
ReplyDelete