数学建模社区-数学中国
标题: 汉诺塔 听说过吧?我知道您肯定没自己做过,现在自己做一下吧 [打印本页]
作者: sea_star666 时间: 2010-1-17 19:45
标题: 汉诺塔 听说过吧?我知道您肯定没自己做过,现在自己做一下吧
本帖最后由 sea_star666 于 2010-1-17 19:52 编辑
Tower of Hanoi
The object is to move all the disks over to another pole. But you cannot place a larger disk onto a smaller disk. Move the disks (with your mouse) onto the pole you wish to move it to.
http://www.mathsisfun.com/games/images/hanoi.swf
作者: 厚积薄发 时间: 2010-1-17 20:00
挺有趣的,6层可真麻烦啊
作者: gk0402jeff 时间: 2010-1-17 20:02
嗯~有点意思
作者: mnpfc 时间: 2010-1-17 20:03
呵呵,来写下步骤吧
不妨把大中小三个圆饼分别编号为c,b,a
step1:move a to tower3
step2:move b to tower2
step3:move a to tower2
step4:move c to tower3
step5:move a to tower1
step6:move b to tower3
step7:move a to tower3
作者: mnpfc 时间: 2010-1-17 20:04
楼层增多了应该会有个算法可以实现的
作者: yichen1988 时间: 2010-1-17 20:07
做了个四层,用了30步,好丢人啊,这个用什么方法能算出来呢?
作者: mnpfc 时间: 2010-1-17 20:31
第一步怎么移,很重要
奇数要移到三
偶数时要移到二
不知道哪个可以证明
作者: mnpfc 时间: 2010-1-17 20:49
作者: isnowfy 时间: 2010-1-17 23:07
n层的至少需要2^n-1步,递归解决就可以
作者: leo12ok 时间: 2010-1-18 08:43
呵呵,4层用了15步。~~~~~~~~~~~~~~~~~~~~~
作者: clanswer 时间: 2010-1-18 13:24
这个在数据结构中是有算法可以实现的哦,呵呵
作者: 13102966666 时间: 2010-1-19 20:40
这个超简单的,我记得小学就玩过~~~
| 欢迎光临 数学建模社区-数学中国 (http://www.madio.net/) |
Powered by Discuz! X2.5 |