matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] # 定义原始矩阵
def add_matrices(n):
result = [] # 定义结果列表
for row in matrix: # 遍历原始矩阵的每一行
new_row = [i * n for i in row] # 将每行的每个元素乘以 n 得到新行
result.append(new_row) # 将新行添加到结果列表
return result # 返回结果
n = int(input()) # 获取输入的整数 n
if 0 < n < 10: # 判断 n 是否在 0 到 10 之间
print(add_matrices(n)) # 输出 n 个矩阵相加的结果



京公网安备 11010502036488号