﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-清清流水-文章分类-程序算法</title><link>http://www.blogjava.net/qinysong/category/14924.html</link><description /><language>zh-cn</language><lastBuildDate>Wed, 04 Apr 2007 08:11:13 GMT</lastBuildDate><pubDate>Wed, 04 Apr 2007 08:11:13 GMT</pubDate><ttl>60</ttl><item><title>AIX 程序设计大赛－AIX正方形问题算法及Java程序实现</title><link>http://www.blogjava.net/qinysong/articles/68023.html</link><dc:creator>qinysong</dc:creator><author>qinysong</author><pubDate>Wed, 06 Sep 2006 06:18:00 GMT</pubDate><guid>http://www.blogjava.net/qinysong/articles/68023.html</guid><wfw:comment>http://www.blogjava.net/qinysong/comments/68023.html</wfw:comment><comments>http://www.blogjava.net/qinysong/articles/68023.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qinysong/comments/commentRss/68023.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qinysong/services/trackbacks/68023.html</trackback:ping><description><![CDATA[   
<div style="TEXT-INDENT: 21pt">昨天晚上，看到CSDN上西部阿呆-小草屋的一篇Blog 《AIX 程序设计大赛---AIX正方形问题》，描述了Aix正方形问题，并给出了Java解决方法，感觉这道题很有趣味和手痒，所以也花了将近一个晚上的时间，用有别于小草屋的思路通过Java程序进行了解决。</div><div style="TEXT-INDENT: 21pt"> </div><div style="TEXT-INDENT: 21pt">由于有很长时间没有接触数学方面的知识了，所以解法上或概念上有什么不对/或不当之处，请对该题也感兴趣的朋友多多指教，希望通过共同探讨找到一个优秀的解决方案。</div><div> </div><div><b>问题描述：</b></div><div style="TEXT-INDENT: 21pt">任意给定一个正方形，将正方形的各边做n等分,并将相应各点连接成水平或垂直的直线,如果从正方形的左下角(0,0)出发,沿各边线或连接线,自左向右或自下而上的方向,到达正方形的右上角(n,n),请用JAVA程序计算并输出所有可能的路径总数和具体线路.请提供相关JAVA源程序和n=2,3,4时的输出结果。输出结果按以下方式:</div><div> </div><div>以n=1为例:</div><div>n = 1</div><div>Path1: (0,0) - (0,1) - (1,1)</div><div>Path2: (0,0) - (1,0) - (1,1)</div><div>Total = 2</div><div> </div><div><b>解决思路：</b></div><div style="TEXT-INDENT: 21pt">通过对上述问题的分析，有一条约束很关键，就是“沿各边线或连接线,自左向右或自下而上的方向,到达正方形的右上角”，根据该约束我们找到一个探寻路径的策略（或称作规则）：向上优先策略，即在探寻一条路径的时候，只要能够向上走，我们就向上走，也就是只在最后一步才向右拐。这样按照这个策略，我们就可以从第一条路径（沿着左边和上边），逐条遍历所有路径。</div><div> </div><div style="TEXT-INDENT: 21pt">确定按照向上优先策略遍历路径后，分析发现，在这个探寻路径的过程中，有一个点非常重要，我在这里称作“顶极点”，定义如下：</div><div style="TEXT-INDENT: 21pt"><b>顶极点：</b>在到达终点point（n，n）之前最后一个拐点，根据这个点是在正方形的上边还是右边，我们分为两种类型：</div><div style="TEXT-INDENT: 21pt">第一种：顶极点是正方形上边上的点，称作为“上边点”</div><div style="TEXT-INDENT: 21pt">第二种：顶极点是正方形右边上的点，称作为“右边点”</div><div> </div><div style="TEXT-INDENT: 21pt">按照向上优先策略，通过上一条路径的顶极点可以唯一确定下一条路径的突破点，突破点定义如下：</div><div style="TEXT-INDENT: 21pt"><b>突破点：</b>下一条路径沿着上一条路径，所走出的第一个不同点。</div><div> </div><div style="TEXT-INDENT: 21pt">通过分析发现突破点和顶极点之间的关系如下：</div><div style="TEXT-INDENT: 21pt">我们设定顶极点为：tipPolePoint（ｘ，ｙ），突破点为breakPoint（ｘ，ｙ）</div><div style="TEXT-INDENT: 21pt">第一种：若顶极点为上边点，则按照向上优先策略，突破点为</div><div style="TEXT-INDENT: 21pt">breakPoint.x = tipPolePoint.x+1</div><div style="TEXT-INDENT: 21pt">breakPoint.y = tipPolePoint.y-1</div><div> </div><div style="TEXT-INDENT: 21pt">第二种：若顶极点为右边点，则按照向上优先策略，突破点为</div><div style="TEXT-INDENT: 21pt">breakPoint.x = (min(x)|y=tipPolePoint.y)+1 （不知道这种表示形式对不对）意思是路径节点中y=tipPolePoint.y的最小 x 值加 1</div><div style="TEXT-INDENT: 21pt">breakPoint.y = tipPolePoint.y-1</div><div> </div><div><b>程序设计：</b></div><div style="TEXT-INDENT: 21pt">根据以上分析，进行Java程序设计，包括三个类，分别简述如下：</div><div style="TEXT-INDENT: 21pt">Point：基础类，表示坐标点；</div><div style="TEXT-INDENT: 21pt">AixUtil：工具类，按照向上优先策略，提供解决AIX正方形问题的一些静态方法；</div><div style="TEXT-INDENT: 21pt">AixClient：一个简单的调用类，通过工具类AixUtil方法，遍历一个正方形的所有路径。</div><div> </div><div><b>源程序代码如下：</b></div><div>Point：基础类，表示坐标点；</div><div>  
<div style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 0.5pt solid; PADDING-LEFT: 5.4pt; BACKGROUND: #e6e6e6; PADDING-BOTTOM: 4px; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 95%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: windowtext 0.5pt solid"><div><span style="COLOR: #0000ff">package</span><span style="COLOR: #000000"> qinysong.aix;<br /><br /></span><span style="COLOR: #008000">/**</span><span style="COLOR: #008000"><br /> * &lt;p&gt;Title: 基础类，表示坐标点&lt;/p&gt;<br /> * &lt;p&gt;Description: AIX 程序设计大赛---AIX正方形问题&lt;/p&gt;<br /> * &lt;p&gt;Copyright: Copyright (c) 2006&lt;/p&gt;<br /> * &lt;p&gt;Company: qinysong&lt;/p&gt;<br /> * </span><span style="COLOR: #808080">@author</span><span style="COLOR: #008000"> zhaoqingsong<br /> * </span><span style="COLOR: #808080">@version</span><span style="COLOR: #008000"> 1.0 $Date: 2006/09/05 21:44:36 $<br /> </span><span style="COLOR: #008000">*/</span><span style="COLOR: #000000"><br /><br /></span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000"> Point {<br />  </span><span style="COLOR: #0000ff">protected</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> x;<br />  </span><span style="COLOR: #0000ff">protected</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> y;<br /><br />  </span><span style="COLOR: #008000">/**</span><span style="COLOR: #008000"><br />   * 构造函数<br />   * </span><span style="COLOR: #808080">@param</span><span style="COLOR: #008000"> x int<br />   * </span><span style="COLOR: #808080">@param</span><span style="COLOR: #008000"> y int<br />   </span><span style="COLOR: #008000">*/</span><span style="COLOR: #000000"><br />  </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> Point(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> x, </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> y){<br />    </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.x </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> x;<br />    </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.y </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> y;<br />  }<br /><br />  </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> String toString(){<br />    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> x </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> y </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">)</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br />  }<br /><br />  </span><span style="COLOR: #008000">/**</span><span style="COLOR: #008000"><br />   * 判断是否为上边点<br />   * </span><span style="COLOR: #808080">@return</span><span style="COLOR: #008000"> boolean<br />   </span><span style="COLOR: #008000">*/</span><span style="COLOR: #000000"><br />  </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">boolean</span><span style="COLOR: #000000"> isTopBorderPoint(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> nValue){<br />    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.y </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> nValue;<br />  }<br /><br />  </span><span style="COLOR: #008000">/**</span><span style="COLOR: #008000"><br />   * 判断thePoint是否与自己相等<br />   * </span><span style="COLOR: #808080">@param</span><span style="COLOR: #008000"> thePoint Point<br />   * </span><span style="COLOR: #808080">@return</span><span style="COLOR: #008000"> boolean<br />   </span><span style="COLOR: #008000">*/</span><span style="COLOR: #000000"><br />  </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">boolean</span><span style="COLOR: #000000"> equals(Point thePoint){<br />    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> (</span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.x </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> thePoint.x) </span><span style="COLOR: #000000">&amp;&amp;</span><span style="COLOR: #000000"> (</span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.y </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> thePoint.y);<br />  }<br /><br />}<br /></span></div></div></div><div> </div><div>AixUtil：工具类，按照向上优先策略，提供解决AIX正方形问题的一些静态方法；</div><div>  
<div style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 0.5pt solid; PADDING-LEFT: 5.4pt; BACKGROUND: #e6e6e6; PADDING-BOTTOM: 4px; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 95%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: windowtext 0.5pt solid"><div><span style="COLOR: #0000ff">package</span><span style="COLOR: #000000"> qinysong.aix;<br /><br /></span><span style="COLOR: #008000">/**</span><span style="COLOR: #008000"><br /> * &lt;p&gt;Title: 工具类，按照向上优先策略，提供解决AIX正方形问题的一些静态方法&lt;/p&gt;<br /> * &lt;p&gt;Description: AIX 程序设计大赛---AIX正方形问题&lt;/p&gt;<br /> * &lt;p&gt;Copyright: Copyright (c) 2006&lt;/p&gt;<br /> * &lt;p&gt;Company: qinysong&lt;/p&gt;<br /> * </span><span style="COLOR: #808080">@author</span><span style="COLOR: #008000"> zhaoqingsong<br /> * </span><span style="COLOR: #808080">@version</span><span style="COLOR: #008000"> 1.0 $Date: 2006/09/05 21:52:18 $<br /> </span><span style="COLOR: #008000">*/</span><span style="COLOR: #000000"><br /><br /></span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000"> AixUtil {<br /><br />  </span><span style="COLOR: #0000ff">private</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">static</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> nValue;<br /><br />  </span><span style="COLOR: #008000">/**</span><span style="COLOR: #008000"><br />   * 初始化正方形边长<br />   * </span><span style="COLOR: #808080">@param</span><span style="COLOR: #008000"> nValue int<br />   </span><span style="COLOR: #008000">*/</span><span style="COLOR: #000000"><br />  </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">static</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> initNValue(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> nValue) {<br />    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (nValue </span><span style="COLOR: #000000">&lt;=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">) {<br />      </span><span style="COLOR: #0000ff">throw</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> RuntimeException(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">初始化正方形边长异常，长度不能小于等于零</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br />    }<br />    AixUtil.nValue </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> nValue;<br />  }<br /><br />  </span><span style="COLOR: #008000">/**</span><span style="COLOR: #008000"><br />   * &lt;p&gt;取得上一条路径的顶极点&lt;/p&gt;<br />   *<br />   * &lt;p&gt;顶极点：在到达最后顶点point（n，n）之前的最后一个拐点，即第一个到达上边或右边的点&lt;br&gt;<br />   * 根据是到达的上边还是右边，顶极点分为两种类型&lt;br&gt;<br />   * 第一种：顶极点是正方形上边上的点，定义为“上边点”&lt;br&gt;<br />   * 第二种：顶极点是正方形右边上的点，定义为“右边点”&lt;/p&gt;<br />   *<br />   * </span><span style="COLOR: #808080">@param</span><span style="COLOR: #008000"> previousPathPoints Point[] 上一条路径节点数组<br />   * </span><span style="COLOR: #808080">@return</span><span style="COLOR: #008000"> Point  tipPolePoint顶极点<br />   </span><span style="COLOR: #008000">*/</span><span style="COLOR: #000000"><br />  </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">static</span><span style="COLOR: #000000"> Point getTipPolePoint(Point[] previousPathPoints) {<br />    Point tipPolePoint </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">;<br />    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> lastIndex </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">nValue;<br />    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (previousPathPoints[lastIndex </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">].y </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> previousPathPoints[lastIndex].y) { </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">取得上边点</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #000000">      </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> lastIndex; i </span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">; i</span><span style="COLOR: #000000">--</span><span style="COLOR: #000000">) {<br />        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (previousPathPoints[i </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">].y </span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000"> previousPathPoints[i].y) {<br />          tipPolePoint </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> previousPathPoints[i];<br />          </span><span style="COLOR: #0000ff">break</span><span style="COLOR: #000000">;<br />        }<br />      }<br />    } </span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"> { </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">取得右边点</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #000000">      </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> lastIndex; i </span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">; i</span><span style="COLOR: #000000">--</span><span style="COLOR: #000000">) {<br />        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (previousPathPoints[i </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">].x </span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000"> previousPathPoints[i].x) {<br />          tipPolePoint </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> previousPathPoints[i];<br />          </span><span style="COLOR: #0000ff">break</span><span style="COLOR: #000000">;<br />        }<br />      }<br />    }<br />    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> tipPolePoint;<br />  }<br /><br />  </span><span style="COLOR: #008000">/**</span><span style="COLOR: #008000"><br />   * &lt;p&gt;取得下一条路径的突破点，返回的突破点定义为breakPoint&lt;br&gt;<br />   * 分两种情况:&lt;br&gt;<br />   * 第一种:若顶极点为上边点,则按照向上优先策略,突破点为&lt;br&gt;<br />   * breakPoint.x = tipPolePoint.x+1&lt;br&gt;<br />   * breakPoint.y = tipPolePoint.y-1&lt;/p&gt;<br />   *<br />   * &lt;p&gt;第二种:若顶极点为右边点,则按照向上优先策略,突破点为&lt;br&gt;<br />   * breakPoint.x = (min(x)|y=tipPolePoint.y)+1  即路径节点中y=tipPolePoint.y的最小 x 值加 1&lt;br&gt;<br />   * breakPoint.y = tipPolePoint.y-1&lt;/p&gt;<br />   *<br />   * </span><span style="COLOR: #808080">@param</span><span style="COLOR: #008000"> previousPathPoints Point[]  路径节点数组,表示上一条路径的节点序列<br />   * </span><span style="COLOR: #808080">@param</span><span style="COLOR: #008000"> tipPolePoint Point 顶极点,表示上一条路径的顶级点<br />   * </span><span style="COLOR: #808080">@return</span><span style="COLOR: #008000"> Point 返回下一条路径的突破点 breakPoint<br />   </span><span style="COLOR: #008000">*/</span><span style="COLOR: #000000"><br />  </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">static</span><span style="COLOR: #000000"> Point getBreakPoint(Point[] previousPathPoints, Point tipPolePoint) {<br />    Point breakPoint </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">;<br />    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> arrayLength </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">nValue</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">;<br />    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> x </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br />    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> y </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br />    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (tipPolePoint.isTopBorderPoint(nValue)) {<br />      x </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> tipPolePoint.x </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">;<br />      y </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> tipPolePoint.y </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">;<br />    } </span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"> {<br />      Point leftPointOnLine </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">;<br />      </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> arrayLength</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">; i </span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">; i</span><span style="COLOR: #000000">--</span><span style="COLOR: #000000">) {<br />        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (previousPathPoints[i].y </span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"> tipPolePoint.y) </span><span style="COLOR: #0000ff">continue</span><span style="COLOR: #000000">;<br />        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (previousPathPoints[i </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">].y </span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000"> previousPathPoints[i].y) {<br />          leftPointOnLine </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> previousPathPoints[i];<br />          </span><span style="COLOR: #0000ff">break</span><span style="COLOR: #000000">;<br />        }<br />      }<br />      x </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> leftPointOnLine.x </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">;<br />      y </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> leftPointOnLine.y </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">;<br />    }<br />    breakPoint </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> Point(x, y);<br />    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> breakPoint;<br />  }<br /><br />  </span><span style="COLOR: #008000">/**</span><span style="COLOR: #008000"><br />   * 按照向上优先策略（即能往上走就往上走），取得下一个路径节点<br />   * </span><span style="COLOR: #808080">@param</span><span style="COLOR: #008000"> currentPoint Point<br />   * </span><span style="COLOR: #808080">@return</span><span style="COLOR: #008000"> Point 下一个路径节点<br />   </span><span style="COLOR: #008000">*/</span><span style="COLOR: #000000"><br />  </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">static</span><span style="COLOR: #000000"> Point getNextPoint(Point currentPoint) {<br />    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> x </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br />    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> y </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br />    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (currentPoint.y </span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000"> nValue) {<br />      x </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> currentPoint.x;<br />      y </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> currentPoint.y </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">;<br />    } </span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (currentPoint.x </span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000"> nValue) {<br />      x </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> currentPoint.x </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">;<br />      y </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> currentPoint.y;<br />    } </span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"> {<br />      </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">;<br />    }<br />    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> Point(x, y);<br />  }<br /><br />  </span><span style="COLOR: #008000">/**</span><span style="COLOR: #008000"><br />   * 按照向上优先策略（即能往上走就往上走），取得下一条路径节点<br />   * </span><span style="COLOR: #808080">@param</span><span style="COLOR: #008000"> previousPathPoints Point[] 上一条路径节点<br />   * </span><span style="COLOR: #808080">@return</span><span style="COLOR: #008000"> Point[] 下一条路径<br />   </span><span style="COLOR: #008000">*/</span><span style="COLOR: #000000"><br />  </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">static</span><span style="COLOR: #000000"> Point[] getNextPath(Point[] previousPathPoints) {<br />    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> arrayLength </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">nValue</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">;<br />    Point tipPolePoint </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> getTipPolePoint(previousPathPoints);<br />    Point breakPoint </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> getBreakPoint(previousPathPoints, tipPolePoint);<br />    Point lastKeepPoint </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> Point(breakPoint.x </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">, breakPoint.y);<br />    Point[] nextPath </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> Point[arrayLength];<br />    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> index </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br />    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (; index </span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000"> arrayLength; index</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">) {<br />      nextPath[index] </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> previousPathPoints[index];<br />      </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (previousPathPoints[index].equals(lastKeepPoint)) {<br />        </span><span style="COLOR: #0000ff">break</span><span style="COLOR: #000000">;<br />      }<br />    }<br />    nextPath[</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">index] </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> breakPoint;<br />    Point tempPoint </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> breakPoint;<br />    </span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000"> ( (tempPoint </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> getNextPoint(tempPoint)) </span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">) {<br />      nextPath[</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">index] </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> tempPoint;<br />    }<br />    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> nextPath;<br />  }<br /><br />  </span><span style="COLOR: #008000">/**</span><span style="COLOR: #008000"><br />   * 按照向上优先策略，取得第一条路径<br />   * </span><span style="COLOR: #808080">@return</span><span style="COLOR: #008000"> Point[]<br />   </span><span style="COLOR: #008000">*/</span><span style="COLOR: #000000"><br />  </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">static</span><span style="COLOR: #000000"> Point[] getFirstPath() {<br />    Point[] firstPath </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> Point[</span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">nValue</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">];<br />    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">; i </span><span style="COLOR: #000000">&lt;=</span><span style="COLOR: #000000"> nValue; i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">) {<br />      firstPath[i] </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> Point(</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">, i);<br />    }<br />    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">; i </span><span style="COLOR: #000000">&lt;=</span><span style="COLOR: #000000"> nValue; i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">) {<br />      firstPath[nValue </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> i] </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> Point(i, nValue);<br />    }<br />    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> firstPath;<br />  }<br /><br />  </span><span style="COLOR: #008000">/**</span><span style="COLOR: #008000"><br />   * &lt;p&gt;按照向上优先策略（即能往上走就往上走），取得下一条路径节点&lt;br&gt;<br />   * 这个函数是上面getNextPath和getFirstPath的合并，用以得到整体的下一条路径&lt;br&gt;<br />   * 如果previousPathPoints 为空，则取得第一条路径&lt;br&gt;<br />   * 如果previousPathPoints不为空，则根据其取得下一条路径&lt;/p&gt;<br />   * </span><span style="COLOR: #808080">@param</span><span style="COLOR: #008000"> previousPathPoints Point[] 上一条路径节点<br />   * </span><span style="COLOR: #808080">@return</span><span style="COLOR: #008000"> Point[] 下一条路径<br />   </span><span style="COLOR: #008000">*/</span><span style="COLOR: #000000"><br />  </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">static</span><span style="COLOR: #000000"> Point[] getTotalNextPath(Point[] previousPathPoints) {<br />    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (previousPathPoints </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">){<br />      </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> getFirstPath();<br />    } </span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"> {<br />      </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> getNextPath(previousPathPoints);<br />    }<br />  }<br /><br />  </span><span style="COLOR: #008000">/**</span><span style="COLOR: #008000"><br />   * 判断是否是最后一条路径<br />   * </span><span style="COLOR: #808080">@param</span><span style="COLOR: #008000"> pathPoints Point[]<br />   * </span><span style="COLOR: #808080">@return</span><span style="COLOR: #008000"> boolean<br />   </span><span style="COLOR: #008000">*/</span><span style="COLOR: #000000"><br />  </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">static</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">boolean</span><span style="COLOR: #000000"> isLastPath(Point[] pathPoints){<br />    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> middleIndex </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> nValue;<br />    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> pathPoints[middleIndex].y </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br />  }<br /><br />  </span><span style="COLOR: #008000">/**</span><span style="COLOR: #008000"><br />   * 按照题目要求格式打印一条路径的节点<br />   * </span><span style="COLOR: #808080">@param</span><span style="COLOR: #008000"> pathNumber int<br />   * </span><span style="COLOR: #808080">@param</span><span style="COLOR: #008000"> pathPoints Point[]<br />   </span><span style="COLOR: #008000">*/</span><span style="COLOR: #000000"><br />  </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">static</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> printlnPathPoints(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> pathNumber, Point[] pathPoints) {<br />    StringBuffer pathStringBuffer </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> StringBuffer();<br />    pathStringBuffer.append(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Path</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> pathNumber </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">：</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br />    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> arrayLength </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">nValue</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">;<br />    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">; i </span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000"> arrayLength; i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">) {<br />      pathStringBuffer.append(pathPoints[i].toString() </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br />    }<br />    String pathString </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> pathStringBuffer.toString();<br />    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (pathString.length()</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">) pathString </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> pathString.substring(</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">,pathString.length()</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">);<br />    System.out.println(pathString);<br />  }<br /><br />}<br /></span></div></div></div><div> </div><div>AixClient：一个简单的调用类，通过工具类AixUtil方法，遍历一个正方形的所有路径。</div><div>  
<div style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 0.5pt solid; PADDING-LEFT: 5.4pt; BACKGROUND: #e6e6e6; PADDING-BOTTOM: 4px; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 95%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: windowtext 0.5pt solid"><div><span style="COLOR: #0000ff">package</span><span style="COLOR: #000000"> qinysong.aix;<br /><br /></span><span style="COLOR: #008000">/**</span><span style="COLOR: #008000"><br /> * &lt;p&gt;Title: 调用类,该类通过工具类AixUtil提供的方法，遍历一个正方形的路径&lt;/p&gt;<br /> * &lt;p&gt;Description: AIX 程序设计大赛---AIX正方形问题&lt;/p&gt;<br /> * &lt;p&gt;Copyright: Copyright (c) 2006&lt;/p&gt;<br /> * &lt;p&gt;Company: qinysong&lt;/p&gt;<br /> * </span><span style="COLOR: #808080">@author</span><span style="COLOR: #008000"> zhaoqingsong<br /> * </span><span style="COLOR: #808080">@version</span><span style="COLOR: #008000"> 1.0 $Date: 2006/09/05 22:49:22 $<br /> </span><span style="COLOR: #008000">*/</span><span style="COLOR: #000000"><br /><br /></span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000"> AixClient {<br /><br />  </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">static</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> main(String[] args) {<br />    System.out.println(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">AixUtil.main begin ......</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br />    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> nValue </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">;<br />    System.out.println(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">当n=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> nValue);<br />    AixUtil.initNValue(nValue);<br />    Point[] pathPoints </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">;<br />    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> pathNumber </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br />    </span><span style="COLOR: #0000ff">do</span><span style="COLOR: #000000"> {<br />      pathPoints </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> AixUtil.getTotalNextPath(pathPoints);<br />      AixUtil.printlnPathPoints(</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">pathNumber, pathPoints);<br />    }</span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000"> (</span><span style="COLOR: #000000">!</span><span style="COLOR: #000000">AixUtil.isLastPath(pathPoints));<br />    System.out.println(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Total：</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> pathNumber);<br /><br />    System.out.println(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">AixUtil.main end   ......</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br />  }<br />}</span></div></div></div><div> </div><div><b>程序输出结果如下：</b></div><div>当ｎ＝２时</div><div>  
<div style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 0.5pt solid; PADDING-LEFT: 5.4pt; BACKGROUND: #e6e6e6; PADDING-BOTTOM: 4px; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 95%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: windowtext 0.5pt solid"><div><img src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" _fcksavedurl="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" /><span style="COLOR: #000000">AixUtil.main begin ......<br /><img src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" _fcksavedurl="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" />当n=2<br /><img src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" _fcksavedurl="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" />Path1：(0,0)-(0,1)-(0,2)-(1,2)-(2,2)<br /><img src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" _fcksavedurl="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" />Path2：(0,0)-(0,1)-(1,1)-(1,2)-(2,2)<br /><img src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" _fcksavedurl="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" />Path3：(0,0)-(0,1)-(1,1)-(2,1)-(2,2)<br /><img src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" _fcksavedurl="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" />Path4：(0,0)-(1,0)-(1,1)-(1,2)-(2,2)<br /><img src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" _fcksavedurl="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" />Path5：(0,0)-(1,0)-(1,1)-(2,1)-(2,2)<br /><img src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" _fcksavedurl="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" />Path6：(0,0)-(1,0)-(2,0)-(2,1)-(2,2)<br /><img src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" _fcksavedurl="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" />Total：6<br /><img src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" _fcksavedurl="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" />AixUtil.main end   ......<br /><img src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" _fcksavedurl="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" /></span></div></div></div><div> </div><div>当ｎ＝３时</div><div>  
<div style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 0.5pt solid; PADDING-LEFT: 5.4pt; BACKGROUND: #e6e6e6; PADDING-BOTTOM: 4px; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 95%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: windowtext 0.5pt solid"><div><span style="COLOR: #000000">AixUtil.main begin ......<br />当n=3<br />Path1：(0,0)-(0,1)-(0,2)-(0,3)-(1,3)-(2,3)-(3,3)<br />Path2：(0,0)-(0,1)-(0,2)-(1,2)-(1,3)-(2,3)-(3,3)<br />Path3：(0,0)-(0,1)-(0,2)-(1,2)-(2,2)-(2,3)-(3,3)<br />Path4：(0,0)-(0,1)-(0,2)-(1,2)-(2,2)-(3,2)-(3,3)<br />Path5：(0,0)-(0,1)-(1,1)-(1,2)-(1,3)-(2,3)-(3,3)<br />Path6：(0,0)-(0,1)-(1,1)-(1,2)-(2,2)-(2,3)-(3,3)<br />Path7：(0,0)-(0,1)-(1,1)-(1,2)-(2,2)-(3,2)-(3,3)<br />Path8：(0,0)-(0,1)-(1,1)-(2,1)-(2,2)-(2,3)-(3,3)<br />Path9：(0,0)-(0,1)-(1,1)-(2,1)-(2,2)-(3,2)-(3,3)<br />Path10：(0,0)-(0,1)-(1,1)-(2,1)-(3,1)-(3,2)-(3,3)<br />Path11：(0,0)-(1,0)-(1,1)-(1,2)-(1,3)-(2,3)-(3,3)<br />Path12：(0,0)-(1,0)-(1,1)-(1,2)-(2,2)-(2,3)-(3,3)<br />Path13：(0,0)-(1,0)-(1,1)-(1,2)-(2,2)-(3,2)-(3,3)<br />Path14：(0,0)-(1,0)-(1,1)-(2,1)-(2,2)-(2,3)-(3,3)<br />Path15：(0,0)-(1,0)-(1,1)-(2,1)-(2,2)-(3,2)-(3,3)<br />Path16：(0,0)-(1,0)-(1,1)-(2,1)-(3,1)-(3,2)-(3,3)<br />Path17：(0,0)-(1,0)-(2,0)-(2,1)-(2,2)-(2,3)-(3,3)<br />Path18：(0,0)-(1,0)-(2,0)-(2,1)-(2,2)-(3,2)-(3,3)<br />Path19：(0,0)-(1,0)-(2,0)-(2,1)-(3,1)-(3,2)-(3,3)<br />Path20：(0,0)-(1,0)-(2,0)-(3,0)-(3,1)-(3,2)-(3,3)<br />Total：20<br />AixUtil.main end   ......<br /></span></div></div></div><div> </div><img src ="http://www.blogjava.net/qinysong/aggbug/68023.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qinysong/" target="_blank">qinysong</a> 2006-09-06 14:18 <a href="http://www.blogjava.net/qinysong/articles/68023.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>