题解 | #牛牛的矩阵乘法#
牛牛的矩阵乘法
http://www.nowcoder.com/practice/4356eb31276b4b7689a4cf0997647f88
x_list = [[13,-1,4],[5,0,6],[1,9,-3]]
for i in range(len(y_list)):
for j in range(len(y_list[i])):
y_list[i][j] += 1
'''
new_list = []
for i in range(len(x_list)):
row_list = list()
for j in range(len(x_list[i])):
value = 0
for k in range(len(x_list[i])):
value += x_list[i][k] * y_list[k][j]
row_list.append(value)
new_list.append(row_list)
print(new_list)
y_list = x_list.copy()
#题目给的输出样例仅为x*x的结果,没有把y拷贝x后+1
'''for i in range(len(y_list)):
for j in range(len(y_list[i])):
y_list[i][j] += 1
'''
new_list = []
for i in range(len(x_list)):
row_list = list()
for j in range(len(x_list[i])):
value = 0
for k in range(len(x_list[i])):
value += x_list[i][k] * y_list[k][j]
row_list.append(value)
new_list.append(row_list)
print(new_list)