题解 | #矩阵乘法#

矩阵乘法

https://www.nowcoder.com/practice/ebe941260f8c4210aa8c17e99cbc663b

x = int(input())
y = int(input())
z = int(input())
A = []
B = []
for _ in range(x):
    A.append(list(map(int, input().split())))

for _ in range(y):
    B.append(list(map(int, input().split())))

C = [[0 for _ in range(z)] for _ in range(x)]

for i in range(x):
    for k in range(z):
        for j in range(y):
            C[i][k] += A[i][j] * B[j][k]

for i in C:
    for j in i:
        print(j, end=" ")
    print() 

全部评论

相关推荐

有工作后先养猫:太好了,是超时空战警,我们有救了😋
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务