Python-汉诺塔问题

def hanoi(n, a, b, c):
    if n > 0:
        hanoi(n - 1, a, c, b)
        print("盘子从%s 移到 %s 了" % (a, c))
        hanoi(n - 1, b, a, c)


hanoi(3, "A", "B", "c")

posted on 2023-02-01 14:18  夜黎i  阅读(21)  评论(0)    收藏  举报

导航