汉诺塔 听说过吧?我知道您肯定没自己做过,现在自己做一下吧
本帖最后由 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 挺有趣的,6层可真麻烦啊 嗯~有点意思 呵呵,来写下步骤吧
不妨把大中小三个圆饼分别编号为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 楼层增多了应该会有个算法可以实现的 做了个四层,用了30步,好丢人啊,这个用什么方法能算出来呢? 第一步怎么移,很重要
奇数要移到三
偶数时要移到二
不知道哪个可以证明
n层的至少需要2^n-1步,递归解决就可以 呵呵,4层用了15步。~~~~~~~~~~~~~~~~~~~~~
页:
[1]
2