Perkalian Matriks 4x4 Di (C++)

Perkalian Matriks 4x4 di C++

c(i,j)=sum(A(i,e)*B(e,j),k=1..4)
with c ,a ,j matrices (1..4)
so u declare three matrices (4*4)and u do calculus


#include<iostrem.h>
int main(void)
{
int A[4][4],B[4][4],C[4][4];
int sum,i,j,e;
// fulling A and B
for (i=0,i<4,i++)
for (j=0,j<4,j++)
cin>>A[i][j];
for (i=0,i<4,i++)
for (j=0,j<4,j++)
cin>>B[i][j];

//calcul of C=A*B
for (i=0,i<4,i++)
for (j=0,j<4,j++)
{
sum=0;
for (e=0,e<4,e++)
sum+=A[i][e]*B[e][j];
C[i][j]=sum;
}

// Menampilkan C
for (i=0,i<4,i++)
for (j=0,j<4,j++)
cout<<C[i][j];
}

Komentar

Posting Komentar

Postingan populer dari blog ini

Interrupt driven I/O

List Linier (Linked list) Dan Variasinya_Struktur Data

Menghitung Jarak Jatuh Peluru (C++)