python3实现简单汉诺塔
2018-03-19 09:00
190 查看
#!/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)
相关文章推荐
- python实现简单问题(汉诺塔、杨辉三角等)
- python实现简单的汉诺塔问题
- 【Python】用递归函数简单实现汉诺塔的移动
- python与百度翻译实现简单词典
- python+flask实现简单博客
- 汉诺塔问题的python实现
- python 实现简单的ExceptionCallHandler装饰器
- 简单的网络爬虫的python实现
- python scrapy简单爬虫记录(实现简单爬取知乎)
- Pexpect简单的测试——一个 expect的python实现
- Python实现简单的记账本功能
- Python简单爬虫实现
- python3音乐播放器简单实现代码
- python实现简单消息总线
- python(1)-实现简单的图片爬虫
- Python实现简单拆分PDF文件的方法
- Python实现简单登录验证
- Python读写json文件的简单实现
- Python实现简单快递查询
- python简单实现linux命令strings