1 def move(n, a, b, c): 2 if n == 1: 3 print(a, '->', c) 4 else: 5 move(n-1, a, c, b) 6 move(1, a, b, c) 7 move(n-1, b, a, c) 8 n = input('请输入塔数:') 9 move(int(n), 'A', 'B', 'C')