+ 1

Can anyone tells me what's wrong to calculate multi of 2 matrices.??

#include <iostream> using namespace std; int main() { int i,j; int A[4][3]{ {1,2,1}, {2,1,0}, {0,0,0}, {5,0,8} }; int B[3][3]{ {3,5,1}, {2,3,4}, {2,6,7} }; for(i=0;i<4;i++){ for(j=0;j<3;j++){ int C[i][j]; C[i][j]=(A[i][j])*(B[i][j])+(A[i][j+1])*(B[i+1][j])+(A[i][j+2])*(B[i+2][j]); cout <<C[i][j]<<"\t"; } cout<<endl;} return 0; }

24th Sep 2019, 2:39 PM
Krimo Setif
Krimo Setif - avatar
2 Respuestas
+ 2
Use C[i][j] = A[i][j] * B[i][j]; in the loop.
24th Sep 2019, 3:16 PM
你知道規則,我也是
你知道規則,我也是 - avatar
0
How??
24th Sep 2019, 3:24 PM
Krimo Setif
Krimo Setif - avatar