深度和广度优先分油问题(C#实现)

[复制链接]
查看11 | 回复0 | 2011-4-11 10:37:51 | 显示全部楼层 |阅读模式
<span class=\"contentad\"></span>
<B style=\"mso-bidi-font-weight: normal\"><SPAN style=\"FONT-SIZE: 22pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">分油问题</SPAN></B><B style=\"mso-bidi-font-weight: normal\"><SPAN lang=EN-US style=\"FONT-SIZE: 22pt\"><?xml:namespace prefix = o ns = \"urn:schemas-microsoft-com:office:office\" /><o:p></o:p></SPAN></B>
<B style=\"mso-bidi-font-weight: normal\"><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">-、问题描述</SPAN></B><B style=\"mso-bidi-font-weight: normal\"><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"><o:p></o:p></SPAN></B>
<SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'\">分油问题:两个小孩去打油,一人带了一个一斤的空瓶,另一个带了一个七两和一个三两的空瓶。原计划各打一斤油,可是由于所带的钱不够,只好合打了一斤油,在回家的路上,二人想平分这一斤油,可是又没有其它工具。现只用这三个瓶子</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">(</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'\">一斤、七两、三两</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">)</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'\">精确地分出两个半斤油来。</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"><o:p></o:p></SPAN>
<B style=\"mso-bidi-font-weight: normal\"><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">二、算法描述</SPAN></B><B style=\"mso-bidi-font-weight: normal\"><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"><o:p></o:p></SPAN></B>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt; COLOR: blue; FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings\"><SPAN style=\"mso-list: Ignore\">F<SPAN style=\"FONT: 7pt \'Times New Roman\'\"> </SPAN></SPAN></SPAN><B style=\"mso-bidi-font-weight: normal\"><SPAN style=\"FONT-SIZE: 14pt; COLOR: blue; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">算法选择</SPAN></B><B style=\"mso-bidi-font-weight: normal\"><SPAN lang=EN-US style=\"FONT-SIZE: 14pt; COLOR: blue\"><o:p></o:p></SPAN></B>
<SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">通过分析题目并结合深度优先、广度优先和迭代加深搜索的算法的特点以及有缺点,这里选择广度优先算法来求解该分油问题。如果采用深度优先算法搜索,由于其盲目性导致搜索陷入局部陷阱,并不一定能求得解即使得到解也不一定是最优解,因此并不采用此算法。迭代加深搜索则是在固定的深度上进行深度和广度搜索结合的策略来进行搜索,这样避免了单一的深度搜索无法得到解的缺点,但是找到的解并不一定是最优解。广度优先以牺牲空间代价和时间代价来换取保证取得最优解。由于该问题并不复杂,即使使用广度优先算法也不会占有太多的空间和时间,因此为了取得最优解这里选择广度优先算法来求解。</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt; COLOR: blue; FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings\"><SPAN style=\"mso-list: Ignore\">F<SPAN style=\"FONT: 7pt \'Times New Roman\'\"> </SPAN></SPAN></SPAN><B style=\"mso-bidi-font-weight: normal\"><SPAN style=\"FONT-SIZE: 14pt; COLOR: blue; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">算法描述</SPAN></B><B style=\"mso-bidi-font-weight: normal\"><SPAN lang=EN-US style=\"FONT-SIZE: 14pt; COLOR: blue\"><o:p></o:p></SPAN></B>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">1. </SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">用</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt; mso-fareast-font-family: 新宋体; mso-font-kerning: 0pt\">unVisitedBttsArr</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">表示初始节点列表</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">(</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">待扩展,此为一个动态数组</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">)<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">2. </SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">如果</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt; mso-fareast-font-family: 新宋体; mso-font-kerning: 0pt\">unVisitedBttsArr</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">为空集,则退出并给出失败信号</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">3. n</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">取为</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt; mso-fareast-font-family: 新宋体; mso-font-kerning: 0pt\">unVisitedBttsArr</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">的第一个节点,并在</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"><SPAN style=\"mso-spacerun: yes\"> </SPAN></SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt; mso-fareast-font-family: 新宋体; mso-font-kerning: 0pt\">unVisitedBttsArr</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">中删除节点</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">n</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">,放入已访问节点列表</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt; mso-fareast-font-family: 新宋体; mso-font-kerning: 0pt\">haveVisitedBttsArr</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">4. </SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">如果</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">n</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">为目标节点,则退出并给出成功信号</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">5. </SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">否则,将</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">n</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">的子节点加到</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">N</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">的末尾,并返回</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">2)</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">步</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt; COLOR: blue; FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings\"><SPAN style=\"mso-list: Ignore\">F<SPAN style=\"FONT: 7pt \'Times New Roman\'\"> </SPAN></SPAN></SPAN><B style=\"mso-bidi-font-weight: normal\"><SPAN style=\"FONT-SIZE: 14pt; COLOR: blue; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">问题分析</SPAN></B><B style=\"mso-bidi-font-weight: normal\"><SPAN lang=EN-US style=\"FONT-SIZE: 14pt; COLOR: blue\"><o:p></o:p></SPAN></B>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt; FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings\"><SPAN style=\"mso-list: Ignore\">l<SPAN style=\"FONT: 7pt \'Times New Roman\'\"> </SPAN></SPAN></SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">选择合适的数据结构表示问题状态</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt; FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings\"><SPAN style=\"mso-list: Ignore\">F<SPAN style=\"FONT: 7pt \'Times New Roman\'\"> </SPAN></SPAN></SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">用向量</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">(T</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">,</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">S</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">,</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">R)</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">表示状态</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">T</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">表示</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">10</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">两瓶中的油量,</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">S</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">表示</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">7</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">两瓶中的油量,</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">R</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">表示</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">3</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">两瓶中的油量。</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt; FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings\"><SPAN style=\"mso-list: Ignore\">F<SPAN style=\"FONT: 7pt \'Times New Roman\'\"> </SPAN></SPAN></SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">问题的起始状态:</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">(10</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">,</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">0</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">,</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">0)</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">。</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt; FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings\"><SPAN style=\"mso-list: Ignore\">F<SPAN style=\"FONT: 7pt \'Times New Roman\'\"> </SPAN></SPAN></SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">问题的目标状态:</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">(5</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">,</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">2</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">,</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">3)</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">或者</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">(5</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">,</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">3</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">,</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">2)</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">或者</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">(5</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">,</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">5</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">,</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">0)</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">。</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt; FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings\"><SPAN style=\"mso-list: Ignore\">l<SPAN style=\"FONT: 7pt \'Times New Roman\'\"> </SPAN></SPAN></SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">确定智能算子,用以表示变化状态的规则。由于总共油量为</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">10</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">两,而</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">10</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">两的瓶可以装满所有的油,因此可以把</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">10</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">两的瓶当作一个大油桶,这样此题就化为和上一题</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">8/6</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">类似的问题了。因此在描述变化状态的时候只需给出</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">7</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">、</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">3</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">瓶的状态即可,</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">10</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">瓶的状态即为</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">10</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">-</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">S</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">-</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">R</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">的油量。可是由于在程序处理上的一致性,在程序的实现上我还是把</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">10</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">、</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">8</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">、</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">6</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">的瓶子统一处理,而不是用两个状态表示。</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"><o:p></o:p></SPAN>
<SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">号</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"><o:p></o:p></SPAN>
<SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">规则</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"><o:p></o:p></SPAN>
<SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">解释</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">1<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">(S,R) and S7 </SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt; FONT-FAMILY: Symbol; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'; mso-char-type: symbol; mso-symbol-font-family: Symbol\"><SPAN style=\"mso-char-type: symbol; mso-symbol-font-family: Symbol\"></SPAN></SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"> (7,R)<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">7</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">斤瓶不满时装满</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">2<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">(S,R) and R 3 </SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt; FONT-FAMILY: Symbol; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'; mso-char-type: symbol; mso-symbol-font-family: Symbol\"><SPAN style=\"mso-char-type: symbol; mso-symbol-font-family: Symbol\"></SPAN></SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"> (S,3)<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">3</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">斤瓶不满时装满</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">3<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">(S,R) and S 0 </SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt; FONT-FAMILY: Symbol; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'; mso-char-type: symbol; mso-symbol-font-family: Symbol\"><SPAN style=\"mso-char-type: symbol; mso-symbol-font-family: Symbol\"></SPAN></SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"> (0,R)<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">7</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">斤瓶不空时倒空</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">4<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">(S,R) and R 0 </SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt; FONT-FAMILY: Symbol; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'; mso-char-type: symbol; mso-symbol-font-family: Symbol\"><SPAN style=\"mso-char-type: symbol; mso-symbol-font-family: Symbol\"></SPAN></SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"> (S,0)<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">3</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">斤瓶不空时倒空</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">5<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">(S,R) and S0 and S R</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">≤</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">3</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt; FONT-FAMILY: Symbol; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'; mso-char-type: symbol; mso-symbol-font-family: Symbol\"><SPAN style=\"mso-char-type: symbol; mso-symbol-font-family: Symbol\"></SPAN></SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"> (0,S R)<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">7</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">斤瓶中油全倒入</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">3</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">斤瓶</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">6<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">(S,R) and R 0 and S R</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">≤</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">7</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt; FONT-FAMILY: Symbol; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'; mso-char-type: symbol; mso-symbol-font-family: Symbol\"><SPAN style=\"mso-char-type: symbol; mso-symbol-font-family: Symbol\"></SPAN></SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"> (S R,0)<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">3</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">斤瓶中油全倒入</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">7</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">斤瓶</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">7<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">(S,R) and S7 and S R</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">≥</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">7</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt; FONT-FAMILY: Symbol; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'; mso-char-type: symbol; mso-symbol-font-family: Symbol\"><SPAN style=\"mso-char-type: symbol; mso-symbol-font-family: Symbol\"></SPAN></SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"> (7, S R -7)<o:p></o:p></SPAN>
<SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">用</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">3</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">斤瓶油装满</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">7</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">斤瓶子</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">8<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">(S,R) and R 3 and S R</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">≥</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">3</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt; FONT-FAMILY: Symbol; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'; mso-char-type: symbol; mso-symbol-font-family: Symbol\"><SPAN style=\"mso-char-type: symbol; mso-symbol-font-family: Symbol\"></SPAN></SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"> (S R -3,3)<o:p></o:p></SPAN>
<SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">用</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">7</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">斤瓶油装满</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">3</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">斤瓶子</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"><o:p></o:p></SPAN>
<B style=\"mso-bidi-font-weight: normal\"><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">三、程序设计</SPAN></B><B style=\"mso-bidi-font-weight: normal\"><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"><o:p></o:p></SPAN></B>
<SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">算法使用</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">C</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">#语言来实现的。程序主要根据上面提供的广度优先算法的描述来对算法进行实现的。程序共有四个类:</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">Bottle</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">类,用来描述瓶子的状态以及一些行为动作和属性。</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">WidthSearch</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">类,是广度优先搜索算法的实现类</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">DepthSearch</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">类,是深度优先搜索算法的实现类</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">MainForm</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">类,是界面设计的类。</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"><o:p></o:p></SPAN>
<SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">这里提供两个算法的实现主要是为了做个对比。</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"><o:p></o:p></SPAN>
<SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">以下主要对几个核心算法的程序实现进行说明介绍。</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 1\"> </SPAN>//</SPAN><SPAN style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\">瓶子类<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\">public</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"> <SPAN style=\"COLOR: blue\">class</SPAN> Bottle<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 1\"> </SPAN>{<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 2\"> </SPAN><SPAN style=\"COLOR: blue\">int</SPAN> Capability = 0 ;//</SPAN><SPAN style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\">瓶子的总容量<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 2\"> </SPAN><SPAN style=\"COLOR: blue\">int</SPAN> Current = 0 ;//</SPAN><SPAN style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\">当前瓶子中的油量<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 2\"> </SPAN><SPAN style=\"COLOR: blue\">int</SPAN> Remain = 0 ;//</SPAN><SPAN style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\">瓶子中剩余的量<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-spacerun: yes\"> </SPAN><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-spacerun: yes\"> </SPAN>//</SPAN><SPAN style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\">倒入油的行为动作<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 2\"> </SPAN><SPAN style=\"COLOR: blue\">public</SPAN> <SPAN style=\"COLOR: blue\">void</SPAN> Add(<SPAN style=\"COLOR: blue\">int</SPAN> val)<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 2\"> </SPAN>{<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 3\"> </SPAN>Current= val;<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 3\"> </SPAN>Remain -= val;<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 2\"> </SPAN>}<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-spacerun: yes\"> </SPAN>//</SPAN><SPAN style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\">倒出油的行为动作<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 2\"> </SPAN><SPAN style=\"COLOR: blue\">public</SPAN> <SPAN style=\"COLOR: blue\">void</SPAN> Sub(<SPAN style=\"COLOR: blue\">int</SPAN> val)<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 2\"> </SPAN>{<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 3\"> </SPAN>Current -= val;<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 3\"> </SPAN>Remain= val;<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 2\"> </SPAN>}<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-spacerun: yes\"> </SPAN>//</SPAN><SPAN style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\">深度优先算法实现类<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 1\"> </SPAN><SPAN style=\"COLOR: blue\">public</SPAN> <SPAN style=\"COLOR: blue\">class</SPAN> DepthSearch<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 2\"> </SPAN><SPAN style=\"COLOR: blue\">public</SPAN> <SPAN style=\"COLOR: blue\">void</SPAN> Searching()<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 2\"> </SPAN>{<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 3\"> </SPAN>Random r = <SPAN style=\"COLOR: blue\">new</SPAN> Random(); <o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 3\"> </SPAN><SPAN style=\"COLOR: blue\">while</SPAN>(bottle_10.CurrentVal != 5) //</SPAN><SPAN style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\">判断是否达到目标状态<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 3\"> </SPAN>{<SPAN style=\"mso-tab-count: 8\"> </SPAN><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 4\"> </SPAN><SPAN style=\"COLOR: blue\">int</SPAN> random = r.Next(1,7);//</SPAN><SPAN style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\">用随机产生的数来随机确定下一个子状态<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 4\"> </SPAN><SPAN style=\"COLOR: blue\">switch</SPAN>(random)<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 4\"> </SPAN>{<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 5\"> </SPAN><SPAN style=\"COLOR: blue\">case</SPAN> 1 : <o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 6\"> </SPAN>FlowTo(bottle_03,bottle_07);<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 6\"> </SPAN><SPAN style=\"COLOR: blue\">break</SPAN>;<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 5\"> </SPAN><SPAN style=\"COLOR: blue\">case</SPAN> 2 :<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 6\"> </SPAN>FlowTo(bottle_10,bottle_03);<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 6\"> </SPAN><SPAN style=\"COLOR: blue\">break</SPAN>;<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 5\"> </SPAN><SPAN style=\"COLOR: blue\">case</SPAN> 3 :<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 6\"> </SPAN>FlowTo(bottle_07,bottle_03);<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 6\"> </SPAN><SPAN style=\"COLOR: blue\">break</SPAN>;<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 5\"> </SPAN><SPAN style=\"COLOR: blue\">case</SPAN> 4 :<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 6\"> </SPAN>FlowTo(bottle_10,bottle_07);<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 6\"> </SPAN><SPAN style=\"COLOR: blue\">break</SPAN>;<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 5\"> </SPAN><SPAN style=\"COLOR: blue\">case</SPAN> 5 :<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 6\"> </SPAN>FlowTo(bottle_03,bottle_10);<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 6\"> </SPAN><SPAN style=\"COLOR: blue\">break</SPAN>;<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 5\"> </SPAN><SPAN style=\"COLOR: blue\">case</SPAN> 6 :<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 6\"> </SPAN>FlowTo(bottle_07,bottle_10);<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 6\"> </SPAN><SPAN style=\"COLOR: blue\">break</SPAN>;<SPAN style=\"mso-tab-count: 1\"> </SPAN><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 5\"> </SPAN><SPAN style=\"COLOR: blue\">default</SPAN> :<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 6\"> </SPAN><SPAN style=\"COLOR: blue\">break</SPAN>;<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 4\"> </SPAN>}<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 4\"> </SPAN><SPAN style=\"COLOR: blue\">if</SPAN>(!stateArr.Contains(BottlesState()))<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 4\"> </SPAN>{<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 5\"> </SPAN>stateArr.Add(BottlesState());<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 4\"> </SPAN>}<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 4\"> </SPAN><SPAN style=\"COLOR: blue\">else<o:p></o:p></SPAN></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 4\"> </SPAN>{<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 5\"> </SPAN>ReturnToPreState();<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 4\"> </SPAN>}<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 3\"> </SPAN>}<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 2\"> </SPAN>}<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-spacerun: yes\"> </SPAN>//</SPAN><SPAN style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\">倒油的动作。这里是从<SPAN lang=EN-US>bottle1</SPAN>倒到<SPAN lang=EN-US>bottle2<o:p></o:p></SPAN></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 2\"> </SPAN><SPAN style=\"COLOR: blue\">private</SPAN> <SPAN style=\"COLOR: blue\">void</SPAN> FlowTo(Bottle bottle1,Bottle bottle2)<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 2\"> </SPAN>{<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 3\"> </SPAN><SPAN style=\"COLOR: blue\">if</SPAN>(bottle1.CurrentValbottle2.RemainVal)<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 3\"> </SPAN>{<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 4\"> </SPAN>bottle1.Sub(bottle2.RemainVal);<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 4\"> </SPAN>bottle2.CurrentVal = bottle2.CapabilityVal;<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 3\"> </SPAN>}<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 3\"> </SPAN><SPAN style=\"COLOR: blue\">else<o:p></o:p></SPAN></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 3\"> </SPAN>{<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 4\"> </SPAN>bottle2.Add(bottle1.CurrentVal);<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 4\"> </SPAN>bottle1.CurrentVal = 0;<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 3\"> </SPAN>}<SPAN style=\"mso-tab-count: 3\"> </SPAN><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 2\"> </SPAN>}<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-spacerun: yes\"> </SPAN>//</SPAN><SPAN style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\">广度优先搜索实现类<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 1\"> </SPAN><SPAN style=\"COLOR: blue\">public</SPAN> <SPAN style=\"COLOR: blue\">class</SPAN> WidthSearch<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 2\"> </SPAN><SPAN style=\"COLOR: blue\">public</SPAN> <SPAN style=\"COLOR: blue\">void</SPAN> S(TreeNode node)<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 2\"> </SPAN>{<SPAN style=\"mso-tab-count: 7\"> </SPAN><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 3\"> </SPAN><SPAN style=\"COLOR: blue\">while</SPAN>(unVisitedBttsArr.Count=0)<SPAN style=\"mso-spacerun: yes\"> </SPAN>//</SPAN><SPAN style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\">未访问表中如果有结点继续循环搜索否则跳出<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 3\"> </SPAN>{<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 4\"> </SPAN>TreeNode n = (TreeNode)unVisitedBttsArr[0];<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 4\"> </SPAN><SPAN style=\"COLOR: blue\">bool</SPAN> flag = <SPAN style=\"COLOR: blue\">true</SPAN>;<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 4\"> </SPAN><SPAN style=\"COLOR: green\">//</SPAN></SPAN><SPAN style=\"FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\">检查是否已经访问过<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 4\"> </SPAN><SPAN style=\"COLOR: blue\">foreach</SPAN>(TreeNode i <SPAN style=\"COLOR: blue\">in</SPAN> haveVisitedBttsArr)<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 4\"> </SPAN>{<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 5\"> </SPAN><SPAN style=\"COLOR: blue\">if</SPAN>(i.Text.Equals(n.Text))<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 5\"> </SPAN>{<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 6\"> </SPAN>haveVisitedBttsArr.Add(unVisitedBttsArr[0]);<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 6\"> </SPAN>unVisitedBttsArr.RemoveAt(0);<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 6\"> </SPAN>flag = <SPAN style=\"COLOR: blue\">false</SPAN>;<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 6\"> </SPAN><SPAN style=\"COLOR: blue\">break</SPAN>;<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 5\"> </SPAN>}<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 4\"> </SPAN>}<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 4\"> </SPAN><SPAN style=\"COLOR: green\">//</SPAN></SPAN><SPAN style=\"FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\">若已经遍历过的不需要继续遍历 跳到下一个<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 4\"> </SPAN><SPAN style=\"COLOR: blue\">if</SPAN>(flag)<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 4\"> </SPAN>{<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 5\"> </SPAN><SPAN style=\"COLOR: blue\">if</SPAN>(Search(n))<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 5\"> </SPAN>{<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 6\"> </SPAN><SPAN style=\"COLOR: blue\">return</SPAN>;<SPAN style=\"mso-tab-count: 2\"> </SPAN><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 5\"> </SPAN>}<SPAN style=\"mso-tab-count: 5\"> </SPAN><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 4\"> </SPAN>}<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 2\"> </SPAN><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 3\"> </SPAN>}<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 2\"> </SPAN>}<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-spacerun: yes\"> </SPAN>//</SPAN><SPAN style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\">创建子结点并加入到<SPAN lang=EN-US>unVisitedBttsArr</SPAN>中。<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 2\"> </SPAN><SPAN style=\"COLOR: blue\">private</SPAN> <SPAN style=\"COLOR: blue\">bool</SPAN> CreateNode(TreeNode node)<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 2\"> </SPAN>{<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 3\"> </SPAN>TreeNode n = <SPAN style=\"COLOR: blue\">new</SPAN> TreeNode(BottlesState());<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 3\"> </SPAN>unVisitedBttsArr.Add(n);<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-spacerun: yes\"></SPAN><SPAN style=\"mso-tab-count: 3\"> </SPAN><SPAN style=\"COLOR: blue\">if</SPAN>(bottle_10.CurrentVal == 5)<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 3\"> </SPAN>{<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 4\"> </SPAN>node.Nodes.Add(n);<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-spacerun: yes\"> </SPAN><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 4\"> </SPAN>SetPath(n);<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 4\"> </SPAN><SPAN style=\"COLOR: blue\">return</SPAN> <SPAN style=\"COLOR: blue\">true</SPAN>;<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 3\"> </SPAN>}<SPAN style=\"mso-spacerun: yes\"> </SPAN><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 3\"> </SPAN>node.Nodes.Add(n);<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 3\"> </SPAN><SPAN style=\"COLOR: blue\">return</SPAN> <SPAN style=\"COLOR: blue\">false</SPAN>;<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 2\"> </SPAN>}<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-spacerun: yes\"> </SPAN>//</SPAN><SPAN style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\">回溯取得最佳路径<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 2\"> </SPAN><SPAN style=\"COLOR: blue\">private</SPAN> <SPAN style=\"COLOR: blue\">void</SPAN> SetPath(TreeNode n)<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 2\"> </SPAN>{<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 3\"> </SPAN><SPAN style=\"COLOR: blue\">while</SPAN>(n.Parent!=<SPAN style=\"COLOR: blue\">null</SPAN>)<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 3\"> </SPAN>{<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 4\"> </SPAN>path = n.Text \" - \" path;<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 4\"> </SPAN>n.ForeColor = System.Drawing.Color.Blue;<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 4\"> </SPAN>n = n.Parent;<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 3\"> </SPAN>}<o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: \'Times New Roman\'; mso-font-kerning: 0pt\"><SPAN style=\"mso-tab-count: 2\"> </SPAN>}<o:p></o:p></SPAN>
<B style=\"mso-bidi-font-weight: normal\"><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"><o:p></o:p></SPAN></B>
<B style=\"mso-bidi-font-weight: normal\"><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"><o:p></o:p></SPAN></B>
<B style=\"mso-bidi-font-weight: normal\"><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">四、试验结果</SPAN></B><B style=\"mso-bidi-font-weight: normal\"><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"><o:p></o:p></SPAN></B>
<SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">如下是试验结果:</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">1</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">)深度优先随机产生子结点的搜索路径</SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"><?xml:namespace prefix = v ns = \"urn:schemas-microsoft-com:vml\" /><v:shapetype id=_x0000_t75 stroked=\"f\" filled=\"f\" path=\"m@4@5l@4@11@9@11@9@5xe\" o:preferrelative=\"t\" o:spt=\"75\" coordsize=\"21600,21600\"><v:stroke joinstyle=\"miter\"></v:stroke><v:formulas><v:f eqn=\"if lineDrawn pixelLineWidth 0\"></v:f><v:f eqn=\"sum @0 1 0\"></v:f><v:f eqn=\"sum 0 0 @1\"></v:f><v:f eqn=\"prod @2 1 2\"></v:f><v:f eqn=\"prod @3 21600 pixelWidth\"></v:f><v:f eqn=\"prod @3 21600 pixelHeight\"></v:f><v:f eqn=\"sum @0 0 1\"></v:f><v:f eqn=\"prod @6 1 2\"></v:f><v:f eqn=\"prod @7 21600 pixelWidth\"></v:f><v:f eqn=\"sum @8 21600 0\"></v:f><v:f eqn=\"prod @7 21600 pixelHeight\"></v:f><v:f eqn=\"sum @10 21600 0\"></v:f></v:formulas><v:path o:connecttype=\"rect\" gradientshapeok=\"t\" o:extrusionok=\"f\"></v:path><o:lock aspectratio=\"t\" v:ext=\"edit\"></o:lock></v:shapetype><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"><o:p><img height=551 src=\"http://www.newasp.net/tech/UploadPic/2005-6/20051126173037208.jpg\" width=616 border=0 onload=\"return imgzoom(this,550);\" onclick=\"javascript:window.open(this.src);\" style=\"cursor:pointer;\"/></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt\">2</SPAN><SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">)广度优先算法实现图<br/></SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"><o:p></o:p></SPAN>
<SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"><o:p><img height=551 src=\"http://www.newasp.net/tech/UploadPic/2005-6/20051126173038373.jpg\" width=616 border=0 onload=\"return imgzoom(this,550);\" onclick=\"javascript:window.open(this.src);\" style=\"cursor:pointer;\"/></o:p></SPAN>
<SPAN style=\"FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman\'\">从以上两个结果来看,如果存在解则广度优先总能找到最优解,但是从时间上来看深度优先更快而广度优先需要遍历每个结点造成时间空间都开销比较大,所以时间上肯定花的比较多。但是可以保证找到最优解。此问题由于比较简单,复杂度不高,只需在第九步就可以找到最优解了,因此深度优先是可取的,但是如果是在某些复杂的问题中,此算法就可能导致组合爆炸,占用空间过大导致算法的不可行。<br/></SPAN><SPAN lang=EN-US style=\"FONT-SIZE: 14pt\"><o:p><br/> 请指点。要源程序的可email给我,代码没有优化。<br/><br/></o:p></SPAN>
</span><br/>
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行