python_汉诺塔
2013-12-06 21:07
246 查看
save as hanoi.py,; then run:
#python hanoi.py 4
#python hanoi.py 4
#!/bin/env python import sys import string def hanoi(floor, towerA, towerB, towerC): if (floor == 1): print('get %s to %s'%(towerA,towerC)) else: hanoi(floor - 1, towerA, towerC, towerB) print('get %s to %s'%(towerA,towerC)) hanoi(floor - 1, towerB, towerA, towerC) a=string.atoi(sys.argv[1]) hanoi(a, 'A', 'B', 'C')
相关文章推荐
- 汉诺塔问题,Python
- python 汉诺塔问题
- 汉诺塔问题分析与python实现
- 用python实现汉诺塔
- 汉诺塔与递归之C++ 和Python实现
- Python_汉诺塔
- python 汉诺塔 Fibonacci数列
- python的递归算法学习(3):汉诺塔递归算法
- python 汉诺塔问题(Tower of Hanoi Puzzle)
- [python]汉诺塔问题求解
- python汉诺塔算法
- 【Python学习】Python解决汉诺塔问题
- 汉诺塔递归Python实现
- python下实现汉诺塔
- 汉诺塔问题之Python
- Python基于递归算法实现的汉诺塔与Fibonacci数列示例
- python数据结构与算法 24 汉诺塔问题(河内塔问题)
- 三柱汉诺塔问题(Python版)
- python实现汉诺塔
- python实现汉诺塔方法汇总