题解 | #矩阵乘法#

矩阵乘法

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

import sys
while True:
    try:
        x = int(input().strip())
        y = int(input().strip())
        z = int(input().strip())
        #分别保存A,B矩阵
        A = []
        for i in range(x):
            A.append(list(map(int,input().strip().split())))
        B = []
#         print(A)
        for j in range(y):
            B.append(list(map(int,input().strip().split())))
#         print(B)
        #计算结果
        SUM = [] 
        for i in range(x):
            SUM.append([0 for i in range(z)])
            for j in range(z):
                for k in range(y):
                    SUM[i][j] += A[i][k] * B[k][j]
        for i in range(len(SUM)):
            print(" ".join(list(map(str,SUM[i]))))
    except:
#         print(sys.exc_info())
        break












全部评论

相关推荐

身边有人上海、深圳 6、7k 都去了,真就带薪上班了。
小浪_coder:深圳除了一些计算机,UI设计,金融类等一些可以月薪过万的工作之外, 认识很多朋友做运营,营销,文员的工作, 月薪基本都在4-6K左右,还有大把人在干
点赞 评论 收藏
分享
06-20 19:40
中原工学院 Java
网络存储:十几天不会让你拉人办卡就结束了吧?
点赞 评论 收藏
分享
06-07 19:59
门头沟学院 C++
补药卡我啊😭:都快15年前的了还在11新特性
你的简历改到第几版了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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