2012年8月26日

摘要: 汉诺塔的变形题目: 现在有多个柱子,柱子上有若干盘子,盘子的摆放要求编号小的盘子一定在编号大的盘子的上面。初始时,若干个盘子分散在这些柱子上,要求实现一个算法,将盘子移动到其他柱子上。 这个题目其实并不是很难,但是一定要分析清楚和能够熟练使用递归算法。#include<iostream>#include<list>#include<stack>#include<algorithm>usingnamespacestd;classHanoiWithStatus{public:HanoiWithStatus(intn){m_pegs=n;Initial 阅读全文
posted @ 2012-08-26 16:54 做个不善的人 阅读(800) 评论(0) 推荐(0)
 
摘要: 多柱汉诺塔可以用Frame–Stewart算法来解决。 The Frame–Stewart algorithm, giving a presumably optimal solution for four (or even more) pegs, is described below: Let be the number of disks. Let be the number of peg... 阅读全文
posted @ 2012-08-26 14:44 做个不善的人 阅读(12015) 评论(0) 推荐(2)