teacher_code_python/汉诺塔.py

9 lines
199 B
Python
Raw Permalink Normal View History

2024-07-14 11:16:59 +08:00
def han(start,end,temp,n):
if n==1:
return 0;
else:
han(start, temp, end, n - 1)
print(n, start, "---->", end)
han(temp, start, end, n - 1)
han("A","B","C",5)