汉诺塔递归函数hanoi
def hanoi(n,src,dst,mid):
global count
if n==1:
print('{}:{}->{}'.format(1,src,dst))
count+=1
else:
hanoi(n-1,src,mid,dst)
print('{}:{}->{}'.format(n,src,dst))
count+=1
hanoi(n-1,mid,dst,src)
count=0
hanoi(3,'A','C','B')
print(count)
def hanoi(n,src,dst,mid):
global count
if n==1:
print('{}:{}->{}'.format(1,src,dst))
count+=1
else:
hanoi(n-1,src,mid,dst)
print('{}:{}->{}'.format(n,src,dst))
count+=1
hanoi(n-1,mid,dst,src)
count=0
hanoi(3,'A','C','B')
print(count)