Python:不打印列表的第一个输入

时间:2019-02-02 12:18:45

标签: python-3.x

问题是:-

从下面三角形的顶部开始,移至下面一行的相邻数字,从上到下的最大总数为。路径以粗体数字表示。

    1 # number of test case
    4 # Number of rows in triangle
    **3**
    **7** 4
    2 **4** 6
    8 5 **9** 3

也就是说,。

从输入中给出的三角形的顶部到底部查找最大总数。

t = int(input())
o = []
for i in range(t):
    n = int(input())
    o = o + [n]

t = int(input())

def maxs(l):
    k = []
    for i in range(l):
        s = list(map(int,input().split()))
        k = k + [s]
    print(k)
    o = max(k[0])
    t = 0
    for i in k:
        u = max(i[t-1:t+2])
        t = i.index(u)
        o = o + u
    return o


for i in  range(t):
    l = int(input())
    print(maxs(l))

为什么我得到的输出是25而不是23?

0 个答案:

没有答案