解题思路:
注意事项:
注意题目要求最后一行不要有多余空格
参考代码:
def f(n,m): A = [[int(j) for j in input().strip().split()] for i in range(n)] B = [[int(j) for j in input().strip().split()] for i in range(n)] C = [[0 for j in range(m)] for i in range(n)] for i in range(n): for j in range(m): C[i][j] = A[i][j]+B[i][j] if m == 1: for i in range(n): for j in range(m): print(C[i][j]) else: for i in range(n): print(C[i][0],end='') for j in range(1,m): print(' {}'.format(C[i][j]),end='') print() if __name__ == '__main__': n,m = map(int,input().strip().split()) f(n,m)
0.0分
0 人评分