def hannota(n, a, c, b): if n==1: print('{}:{}->{}'.format(1,a,c)) else: hannota(n-1,a,b,c) print('{}:{}->{}'.format(n,a,c)) hannota(n-1,b,c,a) def main(): A='A' B='B' C='C' N=eval(input()) hannota(N,A,C,B) main()
来源:https://www.cnblogs.com/qq1294/p/12588449.html