+ 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; }
2 Answers
+ 2
Use C[i][j] = A[i][j] * B[i][j]; in the loop.
0
How??