def hanoi(n, a, b, c):
if n > 0:
hanoi(n - 1, a, c, b)
print('moving the plate from {} to {}'.format(a, c))
hanoi(n - 1, b, a, c)
hanoi(3, 'A', 'B', 'C')
汉诺塔——python数据结构
最新推荐文章于 2025-03-31 17:50:53 发布
def hanoi(n, a, b, c):
if n > 0:
hanoi(n - 1, a, c, b)
print('moving the plate from {} to {}'.format(a, c))
hanoi(n - 1, b, a, c)
hanoi(3, 'A', 'B', 'C')