def hanoi(n, a, b, c):
if n > 0:
hanoi(n - 1, a, c, b)
print("moving from %s to %s" % (a, c))
hanoi(n - 1, b, a, c)
hanoi(3, 'A', 'B', 'C')
汉诺塔问题及其递归算法——python
于 2023-10-11 17:05:55 首次发布
def hanoi(n, a, b, c):
if n > 0:
hanoi(n - 1, a, c, b)
print("moving from %s to %s" % (a, c))
hanoi(n - 1, b, a, c)
hanoi(3, 'A', 'B', 'C')