Discuss / Python / 交作业,按行输出。n= 0 输出:[ ]

交作业,按行输出。n= 0 输出:[ ]

Topic source

孤月情风

#1 Created at ... [Delete] [Delete and Lock User]
def triang(n):
    if n == 0:
        yield []
    else:
        L = [1]
        yield L
        for i in range(n-1):
            L = [1]+[L[n]+L[n+1] for n in range(len(L)-1)]+[1]
            yield L

  • 1

Reply