Discuss / Python / 交作业

交作业

Topic source

wwdx0001

#1 Created at ... [Delete] [Delete and Lock User]

def calculatenext(L): L = L[:] L.append(0) L.insert(0,0) for i in range(len(L)): L[i] = L[i]+L[i] return L

def triangles(): L = [1] while 1: yield L L = calculate_next(L)

def main(): n = 0 for t in triangles(): print(t) n = n + 1 if n == 10: break

wwdx0001

#2 Created at ... [Delete] [Delete and Lock User]

不好意思,发错位置了……T_T


  • 1

Reply