下载汉诺塔ppt
def move(n,A,B,C): if n == 1: print(A,'->',C) else: move(n-1,A,C,B) print(A,'->',C) move(n-1,B,A,C) move(3,'A','B','C')
输出为: A -> C A -> B C -> B A -> C B -> A B -> C A -> C