我想這個代碼,但什麼是錯的如何計算C語言矩陣乘法
for (i = 0; i < row1; i++) {
for (j = 0; j < col2; j++)
suma = 0;
for (l = 0; l < row2; l++)
suma += a[i][l] * bt[l][j];
c[i][j] = suma;
}
printf("\nMultiplication of 2 matrices:\n");
for (i = 0; i < row1; i++) {
for (j = 0; j < col2; j++)
printf("%2d", c[i][j]);
printf("\n");
}
當我調試它,它打印出隨機數的行和列(類似-895473)
http://stackoverflow.com/questions/6311309/how-can-i-multiply-two-matrices-in-c –