Discuss / Python / 汉诺塔 理解了自己敲一遍

汉诺塔 理解了自己敲一遍

Topic source

dreeemer

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

def hanoi(n,a,b,c): if n==1: print('move',a,'-->',c) else: hanoi(n-1,a,c,b) hanoi(1,a,b,c) hanoi(n-1,b,a,c)

hanoi(5,'A','B','C')


  • 1

Reply