题解 | #计算两个矩阵的乘积#
计算两个矩阵的乘积
https://www.nowcoder.com/practice/ed6552d03e624ba58d16af6d57e1c3e9
#include <stdio.h> int main() { int a[3][4], b[4][3]; for (int i = 1; i < 3; i++) { for (int j = 1; j < 4; j++) { scanf("%d", &a[i][j]); } } for (int i = 1; i < 4; i++) { for (int j = 1; j < 3; j++) { scanf("%d", &b[i][j]); } } int a11 = 0, a12 = 0, a21 = 0, a22 = 0; for (int j = 1; j < 4; j++) { a11 += (a[1][j] * b[j][1]); a12 += (a[1][j] * b[j][2]); a21 += (a[2][j] * b[j][1]); a22 += (a[2][j] * b[j][2]); } printf("%d %d\n%d %d\n", a11, a12, a21, a22); return 0; }