#!/usr/bin/env python3
#_*_*_ coding: utf-8 _*_*_
#汉诺塔
# def hannuota(n,N,M):
# print("将第%d块从%s移动到第%s" %(n,N,M))
# def nuota(n,A,B,C):
# if n==1:
# hannuota(1,A,C)
# else:
# nuota(n-1,A,C,B)
# hannuota(n-1,A,C)
# nuota(n-1,B,A,C)
def nuota(n,A,B,C):
if n==1:
# hannuota(1,A,C)
print("将第%d块从%s移动到第%s" %(m,1,A,C))
m = m+1
else:
nuota(n-1,A,C,B)
# hannuota(n-1,A,C)
print("将第%d块从%s移动到第%s" %((m+1),n,A,C))
m = m+1
nuota(n-1,B,A,C)
python3实现简单汉诺塔
最新推荐文章于 2019-10-23 16:31:29 发布