解题思路:
注意事项:
参考代码:
def getNum():
arr = []
line = int(input())
for i in range(line):
s = list(map(int,input().split()))
arr.append(s)
newArr = [[arr[0][0]]]
for i in range(1,len(arr)):
s = []
for j in range(len(arr[i])):
if j == 0:
maxSum = newArr[i - 1][j] + arr[i][j]
elif j == len(arr[i]) - 1:
maxSum = newArr[i - 1][j - 1] + arr[i][j]
else:
maxSum = max(arr[i][j] + newArr[i - 1][j - 1],arr[i][j] + newArr[i - 1][j])
s.append(maxSum)
newArr.append(s)
print(max(newArr[-1]))
n = int(input())
for i in range(n):
getNum()
0.0分
0 人评分
A+B for Input-Output Practice (C++代码)浏览:632 |
不容易系列 (C语言代码)浏览:702 |
数组输出 (C语言代码)--此题的题目描述有问题浏览:1844 |
【出圈】 (C语言代码)浏览:824 |
淘淘的名单 (C语言代码)浏览:1167 |
C二级辅导-公约公倍 (C语言代码)浏览:537 |
妹子杀手的故事 (C语言代码)浏览:1154 |
C语言程序设计教程(第三版)课后习题6.10 (C语言代码)浏览:536 |
C语言程序设计教程(第三版)课后习题7.3 (C语言代码)浏览:420 |
2003年秋浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:748 |