用户:Leo腾查看:0 回复:4 评论:0 创建时间:2019-08-13T18:59:28
想要代码的看这里(其实本来我想用海龟库输入的,为了录制gif的效果我换成了普通输入,所以Import turtle没有删)
import turtle
def hanoi(k, n, a, c, b):
if (n == 0):
return
k -= 1
hanoi(k, n - 1, a, b, c)
print(a, '->', k, '->', c)
hanoi(k, n - 1, b, c, a)
#开始进入Python的世界
num = int(input('num='))
hanoi(num + 1, num, 'a', 'c', 'b')
点赞0
评论
墨染云天imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E7%82%B9%E8%B5%9E.gif"alt="emotion_编程猫_点赞"
点赞0
评论