题解 | #矩阵乘法#
矩阵乘法
https://www.nowcoder.com/practice/ebe941260f8c4210aa8c17e99cbc663b
while 1: try: # 矩阵1的行数,矩阵1列数和2行数,矩阵2列数 a1, a2, a3 = int(input()), int(input()), int(input()) # 矩阵信息 lst01 = [] lst02 = [] for i in range(a1): lst01.append(list(map(int,input().split()))) for i in range(a2): lst02.append(list(map(int, input().split()))) except: break rlst = [[0 for k in range(a3)] for i in range(a1)] for i in range(a1): for j in range(a3): for k in range(a2): rlst[i][j] += lst01[i][k] * lst02[k][j] # 输出 for i in range(a1): for j in range(a3): print(rlst[i][j],end=' ') print()