题解 | #矩阵乘法#

矩阵乘法

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

根据题目描述照着写就行了,最后一行打印不用等矩阵C全部计算完再输出,
每一行计算完之后就可以输出该行了
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]*z for _ in range(x)]
for i in range(x):
    for j in range(z):
        for k in range(y):
            C[i][j]+=A[i][k]*B[k][j]
    print(' '.join(list(map(str,C[i]))))


全部评论

相关推荐

有担当的灰太狼又在摸...:零帧起手查看图片
点赞 评论 收藏
分享
06-26 10:08
门头沟学院 C++
北京Golang实习,一个月4700,吃住都不报,公司位置在海淀。请问友友怎么看呢?如果要租房的话有什么建议吗
码农索隆:租房肯定是合租了,剩下的钱,差不多够正常吃饭了,看看能不能学到东西吧
点赞 评论 收藏
分享
评论
点赞
1
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务