标签:def pre print lse coding highlight else move pytho
# -*- coding: utf-8 -*- def move(n, a, b, c): if n==1: print(a,‘==>‘,c)#只有一块的时候直接从A到C即可 else: move(n-1,a,c,b)#把n-1块从a先移到B print(a,‘==>‘,c)#把第n块先从a先到c move(n-1,b,a,c)#再把原来从a移到B上的n-1块,从B移到c, # 期待输出: # A --> C # A --> B # C --> B # A --> C # B --> A # B --> C # A --> C move(3, ‘A‘, ‘B‘, ‘C‘)
标签:def pre print lse coding highlight else move pytho
原文地址:https://www.cnblogs.com/chengye2000/p/9062696.html