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步。~~~~~~~~~~~~~~~~~~~~~
页: [1] 2
查看完整版本: 汉诺塔 听说过吧?我知道您肯定没自己做过,现在自己做一下吧