最终还是百度了下。。思维模式要改一下囧
Topic source修正下:
def move(n, a, b, c):
if n==1:
print(a,'-->',c)
else:
move(n-1,a,c,b)
move(1,a,b,c)
move(n-1,b,a,c)
n=input('pls input number:')
move(int(n),'A','B','C')
- 1
修正下:
def move(n, a, b, c):
if n==1:
print(a,'-->',c)
else:
move(n-1,a,c,b)
move(1,a,b,c)
move(n-1,b,a,c)
n=input('pls input number:')
move(int(n),'A','B','C')
天朝子民