+ 4
why is this code not working? im trying A*B=C
6 Antworten
+ 8
Your matrixes are 10x10 but when you initialize them your are iterating only up to 3 lines and 3 columns.
Try to change their sizes to 3x3 or iterate over all 10 lines and 10 columns.
+ 9
Țucudean Adrian-Ionuț The only thing I can think of is the numbers in matrix `c` are overflowing after you do the product.
Try finding a way to limitate the range in which you are generating the numbers in matrixes `a` and `b`. 👍🏻
Edit: actually no... I'll check it more carefully after I get home.
Edit2: I really don't know why it's not working properly...
I'll leave this for your reference: https://www.sanfoundry.com/cpp-program-perform-matrix-multiplication/
+ 8
Țucudean Adrian-Ionuț You are using i, j and k to iterate over `c`... that's because you are doing the matrix product.
Try printing matrix `c` in another loop after doing the product, using only i and j as in:
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
cout << c[i][j] << "|";
}
cout << endl;
}
In other words, separate product calculation process from the printing process... (sorry if this got a bit confusing)
+ 4
still not working
+ 4
lool those 3 (for) are confuzing i cant follow with mi mind the entire code
+ 3
look at this, now is working fine but the results are still false (this code is giving me an headache)