汉诺塔

it2024-12-14  14

https://www.cnblogs.com/dmego/p/5965835.html https://blog.csdn.net/gui951753/article/details/79538799

count1=0 def hanoi1(n,a,b,c): global count1 if n==1: print("{}->{}".format(a,c)) count1+=1 else: hanoi1(n-1,a,c,b) print("{}->{}".format(a,c)) count1+=1 hanoi1(n-1,b,a,c) return count1 def main(): print(hanoi1(3,"a","b","c")) main()
最新回复(0)