题解 | #矩阵乘法#

矩阵乘法

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

from pickle import LIST
x = int(input())
y = int(input())
z = int(input())
A = []
B = []
C = [[0 for j in range(z)] for i in range(x)]

for i in range(x):
    A.append(list(map(int,input().split())))

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

for i in range(x):
    for k in range(z):
        sum = 0
        for j in range(y):
            sum += A[i][j] * B[j][k]
            C[i][k] = sum
for i in C:
    for j in i:
        print(j,end=' ')
    print()

全部评论

相关推荐

11-01 08:48
门头沟学院 C++
伤心的候选人在吵架:佬你不要的,能不能拿户口本证明过户给我。。球球了
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务