<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dcterms="http://purl.org/dc/terms/">
 <channel>
  	  <title><![CDATA[long1 vs longpo]]></title>
	  <link>http://blog.163.com/lfw2565295@126</link>
	  <description><![CDATA[back 输得起，才会赢。。。]]></description>
	  <language>zh-CN</language>
	  <pubDate>Fri, 25 May 2012 00:34:17 +0800</pubDate>
	  <lastBuildDate>Fri, 25 May 2012 00:34:17 +0800</lastBuildDate>
	  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
	  <generator><![CDATA[NetEase Space]]></generator>
	  <managingEditor><![CDATA[lfw2565295@126]]></managingEditor>
	  <webMaster><![CDATA[long1]]></webMaster>
		  <ttl>120</ttl>
	  <image>
	  	<title><![CDATA[long1 vs longpo]]></title>
	  	<url>http://img.bimg.126.net/photo/C2ioRmFBjoolPWCbnCW6Kw==/173951535608633502.jpg</url>
	  	<link>http://blog.163.com/lfw2565295@126</link>
	  </image>
  <item>
  	<title><![CDATA[屌丝们！ 别看片别强撸别搬砖了！！！！ 看看你们应该怎样逆袭！]]></title>	
    <link>http://blog.163.com/lfw2565295@126/blog/static/1220051620124239406417</link>
    <description><![CDATA[<div><div><img title="屌丝们！ 别看片别强撸别搬砖了！！！！ 看看你们应该怎样逆袭！ - long1 - long1 vs longpo"  alt="屌丝们！ 别看片别强撸别搬砖了！！！！ 看看你们应该怎样逆袭！ - long1 - long1 vs longpo"  style="margin:0 10px 0 0;"  src="http://img9.ph.126.net/5C3cKk7hLnNDrt3xh7roRg==/2736499723598547849.jpg"  ></div><div><font size="4"  color="#0000ff"  ><b><br></b></font></div><div><font size="4"  color="#0000ff"  ><b>屌丝需要逆袭</b></font></div><div><font size="4"  color="#0000ff"  ><b>不需要高帅富，但需要有自我！！</b></font></div>&nbsp;<wbr></div>]]></description>
	    <author><![CDATA[long1]]></author>
	    <comments>http://blog.163.com/lfw2565295@126/blog/static/1220051620124239406417</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/lfw2565295@126/blog/static/1220051620124239406417</guid>
    <pubDate>Wed, 23 May 2012 21:40:06 +0800</pubDate>
    <dcterms:modified>2012-05-23T21:40:06+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[520晚安！]]></title>	
    <link>http://blog.163.com/lfw2565295@126/blog/static/12200516201242105420100</link>
    <description><![CDATA[<div><div><div><font size="3"  >&nbsp; </font><font size="3"  color="#0000ff"  ><b>&nbsp; &nbsp; &nbsp; 世界上最遥远的距离不是生与死，而是我站在你面前，你却不知道我爱你；</b></font></div><div><font size="3"  color="#0000ff"  ><b>　　世界上最遥远的距离不是我在站在你面前，你不知道我爱你，而是明明相爱却不能在一起；</b></font></div><div><font size="3"  color="#0000ff"  ><b>　　世界上最遥远的距离不是明明相爱却不能在一起，而是明明无法抵挡这种思念，却还得故意装作丝毫没有把你放在心上。</b></font></div><div><font size="3"  color="#0000ff"  ><b>　　人生总会有物是人非的感慨和无奈，而最令人心碎的莫过于错过爱情。</b></font></div><div><font size="3"  color="#0000ff"  ><b>&nbsp; &nbsp; 今天是5月20日，也就是传说中的520(我爱你),更是2012年的520，也许这一年会是世界末日，在世界末日前的520，是不是真的有一种生离死别的滋味。缘起缘灭缘自在，情深情浅不由人，在死亡面前，什么都是那么真，人这一生，能有一份真挚的感情，是多么难能可贵。</b></font></div><div><font size="3"  color="#0000ff"  ><b>&nbsp; &nbsp; 爱情这玩意，能诗能画，也可粗茶淡饭，平日里，表现的很多刻意，很多误会，原本快因爱成恨相互烦躁，突然因为简单的一句表白，顿时化开所有矛盾，原来所有的事，都因爱由生，因爱而灭。所以即使老的发俗的剧本，韩剧也能让一大堆人内流满面：</b></font></div><div><font size="3"  color="#0000ff"  ><b>&nbsp; &nbsp; "你知道我找你有多辛苦吗，就留下一封信，还联系不上，你想让我急死吗，你为什么要把我变成这样，你为什么让我变成这副境地，昨天一天又心痛又心跳闷闷的，都快炸掉了，呼吸都困难的我，自己都不知道是怎么回事，一天到晚差点疯了，喊得撕心裂肺也没觉得舒服点，但是现在看到你的脸我知道。。。我，原来一天都在想念你，我。。。喜欢你！"</b></font></div><div><font size="3"  color="#0000ff"  ><b>&nbsp; &nbsp; 这是最近电视剧《屋塔房王世子》里男主角向女主角告白的台词，其实说的都没什么逻辑了，但似乎感情就是这样，越乱，越明白。</b></font></div><div><font size="3"  color="#0000ff"  ><b>&nbsp; &nbsp; 一个拥抱，一个吻，或许，没有什么语言比这几个简单的动作。之后，就觉得之前的行为傻乎乎，但又傻得可爱。</b></font></div><div><font size="3"  color="#0000ff"  ><b>&nbsp; &nbsp; 嘻哈四重奏4，经理傻傻的追求了小乔多次，海边浪漫又荒唐，让整个剧情变得搞笑而生动，最后在海边表白了，笑着笑着，就感动了，原来过去一幕幕傻动作，会让最后的表白如此动情，如此难以忘怀！</b></font></div><div><font size="3"  color="#0000ff"  ><b>&nbsp; &nbsp; 在师大六年了，好多520悄无声息的流逝了，快离开之际，猛然发现，美好的大学校园在某一天某一个角落，也应该留下很多难以忘怀的瞬间，哪怕似乎已近弥留之际，留下点情怀。</b></font></div><div><font size="3"  color="#0000ff"  ><b>&nbsp; &nbsp; 突然想听那首歌《海之花》，嘻哈四重奏的主题曲。</b></font></div><div><font size="3"  color="#0000ff"  ><b>&nbsp; &nbsp; 是流星就有它瞬间的美丽，是花蕾就注定有它的绽放，就像鸟儿在天空中翱翔，鱼儿在水中游弋。纵然，我的生命是一片辽阔的天空，也不愿你是一颗稍纵即逝的流星！我宁愿你的耀眼是一种永恒；我宁愿你的美丽是一种深邃；我宁愿你的微笑呈绽一种幸福；我宁愿你的不经意透视一种抚慰……</b></font></div><div><br></div><div><font size="3"  color="#ff0000"  ><b>歌词：</b></font></div><div><font size="3"  color="#ff0000"  ><b>望着这片海</b></font></div><div><font size="3"  color="#ff0000"  ><b>泪水流下来</b></font></div><div><font size="3"  color="#ff0000"  ><b>我的心中有无限的感慨</b></font></div><div><font size="3"  color="#ff0000"  ><b>被风吹过的地方</b></font></div><div><font size="3"  color="#ff0000"  ><b>看来有些乱</b></font></div><div><font size="3"  color="#ff0000"  ><b>其实心很冷很孤单</b></font></div><div><font size="3"  color="#ff0000"  ><b><br></b></font></div><div><font size="3"  color="#ff0000"  ><b>望着这片海</b></font></div><div><font size="3"  color="#ff0000"  ><b>幻想着未来</b></font></div><div><font size="3"  color="#ff0000"  ><b>我的心中仿佛有了依赖 oh~</b></font></div><div><font size="3"  color="#ff0000"  ><b>过去的伤痕留给岁月做尘埃</b></font></div><div><font size="3"  color="#ff0000"  ><b>这些年却越变越实在</b></font></div><div><font size="3"  color="#ff0000"  ><b><br></b></font></div><div><font size="3"  color="#ff0000"  ><b>我的爱</b></font></div><div><font size="3"  color="#ff0000"  ><b>已经消失在从前那片海</b></font></div><div><font size="3"  color="#ff0000"  ><b>耳边却依然回荡着对海的誓言</b></font></div><div><font size="3"  color="#ff0000"  ><b>我的爱</b></font></div><div><font size="3"  color="#ff0000"  ><b>依然停留在从前那片海</b></font></div><div><font size="3"  color="#ff0000"  ><b>因为爱</b></font></div><div><font size="3"  color="#ff0000"  ><b>深深沉入这片海</b></font></div><div><font size="3"  color="#ff0000"  ><b>（Music）啊~~~~</b></font></div><div><font size="3"  color="#ff0000"  ><b>望着这片海</b></font></div><div><font size="3"  color="#ff0000"  ><b>幻想着未来</b></font></div><div><font size="3"  color="#ff0000"  ><b>我的心中仿佛有了依赖 oh~</b></font></div><div><font size="3"  color="#ff0000"  ><b>过去的伤痕留给岁月做尘埃</b></font></div><div><font size="3"  color="#ff0000"  ><b>这些年却越变越实在</b></font></div><div><font size="3"  color="#ff0000"  ><b><br></b></font></div><div><font size="3"  color="#ff0000"  ><b>我的爱</b></font></div><div><font size="3"  color="#ff0000"  ><b>已经消失在从前那片海</b></font></div><div><font size="3"  color="#ff0000"  ><b>耳边却依然回荡着对海的誓言</b></font></div><div><font size="3"  color="#ff0000"  ><b>我的爱</b></font></div><div><font size="3"  color="#ff0000"  ><b>依然停留在从前那片海</b></font></div><div><font size="3"  color="#ff0000"  ><b>因为爱</b></font></div><div><font size="3"  color="#ff0000"  ><b>深深沉入这片海</b></font></div><div><font size="3"  color="#ff0000"  ><b><br></b></font></div><div><font size="3"  color="#ff0000"  ><b>望着宁静的大海</b></font></div><div><font size="3"  color="#ff0000"  ><b>望着再也不回来的爱和海阔天空的未来</b></font></div><div><font size="3"  color="#ff0000"  ><b><br></b></font></div><div><font size="3"  color="#ff0000"  ><b>我的爱</b></font></div><div><font size="3"  color="#ff0000"  ><b>已经消失在从前那片海</b></font></div><div><font size="3"  color="#ff0000"  ><b>耳边却依然回荡着对海的誓言</b></font></div><div><font size="3"  color="#ff0000"  ><b>我的爱</b></font></div><div><font size="3"  color="#ff0000"  ><b>依然停留在从前那片海</b></font></div><div><font size="3"  color="#ff0000"  ><b>因为爱</b></font></div><div><font size="3"  color="#ff0000"  ><b>深深沉入这片海</b></font></div><div><font size="3"  color="#ff0000"  ><b><br></b></font></div><div><font size="3"  color="#ff0000"  ><b>因为爱</b></font></div><div><font size="3"  color="#ff0000"  ><b>深深沉入我心海</b></font></div><div><br></div><div><a target="_blank" rel="nofollow" href="http://v.youku.com/v_show/id_XMzc5NzkyOTM2.html"  >http://v.youku.com/v_show/id_XMzc5NzkyOTM2.html</a></div><div><br></div><div><embed height="300" style="margin:5px;" pluginspage="http://www.macromedia.com/go/getflashplayer" allowScriptAccess="never" width="500" quality="high" invokeurls="false" src="http://player.youku.com/player.php/sid/XMzc5NzkyOTM2/v.swf" type="application/x-shockwave-flash" wmode="transparent"  >&nbsp;</div></div><wbr></div>]]></description>
	    <author><![CDATA[long1]]></author>
	    <comments>http://blog.163.com/lfw2565295@126/blog/static/12200516201242105420100</comments>
    <slash:comments>4</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/lfw2565295@126/blog/static/12200516201242105420100</guid>
    <pubDate>Mon, 21 May 2012 00:54:20 +0800</pubDate>
    <dcterms:modified>2012-05-21T00:57:52+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[1020	AOE网络 拓扑排序]]></title>	
    <link>http://blog.163.com/lfw2565295@126/blog/static/1220051620124193143686</link>
    <description><![CDATA[<div><div><span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-family: Simsun; line-height: normal; font-size: medium;"  ><div lang="en-US"  style="text-align: center; font-family: Arial, Helvetica, sans-serif; font-size: 18pt; font-weight: bold; color: blue;"  >AOE网络</div><div style="text-align: center; font-family: Arial, Helvetica, sans-serif; font-size: 12pt;"  ><br><font color="read"  >Case Time Limit:0MS</font><table align="center"  ><tbody><tr><td><b>Time Limit:</b>&nbsp;1000MS</td><td width="10px"  ></td><td colspan="3"  ><b>Memory Limit:</b>&nbsp;65536K</td></tr><tr><td><b>Total Submissions:</b>&nbsp;9</td><td width="10px"  ></td><td><b>Accepted:</b>&nbsp;4</td></tr></table></div><p style="text-align: left; font-family: Arial, Helvetica, sans-serif; font-size: 18pt; font-weight: bold; color: blue;"  >Description</p><div lang="en-US"  style="font-family: 'Times New Roman', Times, serif; font-size: 12pt;"  >AOE网络：Activity on edge network，若在带权的有向图中，以顶点表示事件，以有向边表示活动，边上的权值表示活动的开销（如该活动持续的时间），则此带权的有向图称为AOE网。 如果用AOE网来表示一项工程，那么，仅仅考虑各个子工程之间的优先关系还不够，更多的是关心整个工程完成的最短时间是多少。在项目管理中，关键路径是指网络终端元素的元素的序列，该序列具有最长的总工期并决定了整个项目的最短完成时间。现在给定一个AOE网络，求出它的关键路径的长度。</div><p style="text-align: left; font-family: Arial, Helvetica, sans-serif; font-size: 18pt; font-weight: bold; color: blue;"  >Input</p><div lang="en-US"  style="font-family: 'Times New Roman', Times, serif; font-size: 12pt;"  >输入数据第一行，两个整数n和m,表示工程个数具有优先关系的工程对数。接下来一行n个数，表示完成每个工程所需要的时间，接下来m行，每行两个整数a，b,表示要完成b，需要先完成a。(1&lt;=a,b&lt;=n,a!=b，1&lt;=n&lt;=100)。</div><p style="text-align: left; font-family: Arial, Helvetica, sans-serif; font-size: 18pt; font-weight: bold; color: blue;"  >Output</p><div lang="en-US"  style="font-family: 'Times New Roman', Times, serif; font-size: 12pt;"  >输出一个整数，表示关键路径的长度，即完成整个项目需要花费的最少时间。</div><p style="text-align: left; font-family: Arial, Helvetica, sans-serif; font-size: 18pt; font-weight: bold; color: blue;"  >Sample Input</p><pre><div lang="en-US"  style="font-family: 'Times New Roman', Times, serif; font-size: 12pt;"  > 5 5 1 2 3 4 5 1 2 1 3 1 4 2 5 3 5</div></pre><p style="text-align: left; font-family: Arial, Helvetica, sans-serif; font-size: 18pt; font-weight: bold; color: blue;"  >Sample Output</p><pre><div lang="en-US"  style="font-family: 'Times New Roman', Times, serif; font-size: 12pt;"  > 9</div></pre><p style="text-align: left; font-family: Arial, Helvetica, sans-serif; font-size: 18pt; font-weight: bold; color: blue;"  >Hint</p><div lang="en-US"  style="font-family: 'Times New Roman', Times, serif; font-size: 12pt;"  >一条关键路径为1 3 5</div><div lang="en-US"  style="font-family: 'Times New Roman', Times, serif; font-size: 12pt;"  ><br></div></span></div><div><b><font size="4"  color="#0000ff"  >方法1： 拓扑排序</font></b></div><div>#include&lt;cstdio&gt;</div><div>#include&lt;vector&gt;</div><div>#include&lt;iostream&gt;</div><div>#include&lt;cstring&gt;</div><div>using namespace std;</div><div>int n,m;</div><div>int de[205],ans[205];</div><div>vector&lt;int&gt; ne[205];</div><div>bool out[205];</div><div>int val[205];</div><div>int main(){</div><div><span style="white-space:pre;"  > </span>int i,j,cas,a,b;</div><div><span style="white-space:pre;"  > </span>while( scanf("%d%d",&amp;n,&amp;m) != EOF ){</div><div><span style="white-space:pre;"  >  </span>for(i=1; i&lt;=n; i++) scanf("%d",&amp;val[i]);</div><div><span style="white-space:pre;"  >  </span>for(i=1; i&lt;=n; i++) {</div><div><span style="white-space:pre;"  >   </span>ne[i].clear(); out[i]=false;</div><div><span style="white-space:pre;"  >  </span>}</div><div><span style="white-space:pre;"  >  </span>for(i=0; i&lt;m; i++){</div><div><span style="white-space:pre;"  >   </span>scanf("%d%d",&amp;a,&amp;b);</div><div><span style="white-space:pre;"  >   </span>if(a!=b) ne[a].push_back(b);</div><div><span style="white-space:pre;"  >  </span>}</div><div><span style="white-space:pre;"  >  </span>bool f=0;</div><div><span style="white-space:pre;"  >  </span>for(j=1; j&lt;=n; j++){</div><div><span style="white-space:pre;"  >   </span>memset(de,0,sizeof(de));</div><div><span style="white-space:pre;"  >   </span>if(f) break;</div><div><span style="white-space:pre;"  >   </span>for(i=1; i&lt;=n; i++){ &nbsp;//拓扑排序，很土</div><div><span style="white-space:pre;"  >    </span>if(out[i]) continue;</div><div><span style="white-space:pre;"  >    </span>int s=ne[i].size(),k,v;</div><div><span style="white-space:pre;"  >    </span>for(k=0; k&lt;s; k++){</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //printf("%d %d\n",i,ne[i][k]);</div><div><span style="white-space:pre;"  >     </span>v=ne[i][k]; &nbsp;de[v]++;</div><div><span style="white-space:pre;"  >    </span>}</div><div><span style="white-space:pre;"  >   </span>}<span style="white-space:pre;"  >  </span></div><div><span style="white-space:pre;"  >   </span>for(i=1; i&lt;=n; i++){ &nbsp;//从重的开始赋值</div><div><span style="white-space:pre;"  >    </span>if(de[i]==0 &amp;&amp; !out[i]){&nbsp;</div><div><span style="white-space:pre;"  >     </span>ans[j]=i; &nbsp;out[i]=true; &nbsp;break;</div><div><span style="white-space:pre;"  >    </span>}</div><div><span style="white-space:pre;"  >   </span>}</div><div><span style="white-space:pre;"  >   </span>if(i==0) f=1; &nbsp;//有环了</div><div><span style="white-space:pre;"  >  </span>}</div><div><span style="white-space:pre;"  >  </span>if(f) { printf("Impossible\n"); while(1); continue; }</div><div><span style="white-space:pre;"  >  </span>//for(i=1; i&lt;=n; i++) printf("%d ",ans[i]);</div><div><span style="white-space:pre;"  >  </span>int res=0;</div><div><span style="white-space:pre;"  >  </span>int t[205];</div><div><span style="white-space:pre;"  >  </span>for(i=1; i&lt;=n; i++) t[i]=0;</div><div><span style="white-space:pre;"  >  </span>for(i=1; i&lt;=n; i++){</div><div><span style="white-space:pre;"  >   </span>int x=ans[i];</div><div><span style="white-space:pre;"  >   </span>t[x]+=val[x];</div><div><span style="white-space:pre;"  >   </span>res=max(res, t[x]);</div><div><span style="white-space:pre;"  >   </span>for(j=0; j&lt;ne[x].size(); j++){</div><div><span style="white-space:pre;"  >   </span> &nbsp; &nbsp;t[ne[x][j]]=max(t[ne[x][j]], t[x]);</div><div><span style="white-space:pre;"  >   </span>}</div><div><span style="white-space:pre;"  >  </span>}</div><div>&nbsp;<span style="white-space:pre;"  >  </span>printf("%d\n",res);</div><div><span style="white-space:pre;"  > </span>}</div><div><span style="white-space:pre;"  > </span>return 0;</div><div>}</div><div><br></div><div><font size="4"  color="#0000ff"  ><b><br></b></font></div><div><font size="4"  color="#0000ff"  ><b>方法2：BFS</b></font></div><div><span style="font-family: Simsun; line-height: normal; font-size: medium;"  ><pre style="background-color: rgb(255, 255, 255); color: rgb(0, 0, 0); font-weight: normal; font-style: normal;"  ><span style="color: rgb(63, 95, 191); font-weight: normal; font-style: normal;"  >#include</span><span style="color: rgb(0, 0, 255); font-weight: normal; font-style: normal;"  >&lt;stdio.h&gt;</span> <span style="color: rgb(63, 95, 191); font-weight: normal; font-style: normal;"  >#include</span><span style="color: rgb(0, 0, 255); font-weight: normal; font-style: normal;"  >&lt;string.h&gt;</span> <span style="color: rgb(63, 95, 191); font-weight: normal; font-style: normal;"  >#define</span> M <span style="color: rgb(0, 0, 0); font-weight: normal; font-style: normal;"  >105</span> <span style="color: rgb(127, 0, 85); font-weight: bold; font-style: normal;"  >int</span> cost<span>[</span>M<span>],</span>Indegree<span>[</span>M<span>],</span>Outdegree<span>[</span>M<span>];</span> <span style="color: rgb(127, 0, 85); font-weight: bold; font-style: normal;"  >int</span> map<span>[</span>M<span>][</span>M<span>];</span> <span style="color: rgb(127, 0, 85); font-weight: bold; font-style: normal;"  >int</span> Q<span>[</span>M<span>],</span>dis<span>[</span>M<span>];</span> <span style="color: rgb(127, 0, 85); font-weight: bold; font-style: normal;"  >int</span> <span style="color: rgb(0, 0, 0); font-weight: normal; font-style: normal;"  >solve</span><span>(</span><span style="color: rgb(127, 0, 85); font-weight: bold; font-style: normal;"  >int</span> n<span>)</span><span>{</span>  <span style="color: rgb(127, 0, 85); font-weight: bold; font-style: normal;"  >int</span> L<span>,</span>H<span>,</span>i<span>,</span>k<span>,</span>y<span>;</span>  L<span>=</span><span style="color: rgb(0, 0, 0); font-weight: normal; font-style: normal;"  >0</span><span>,</span>H<span>=</span><span style="color: rgb(0, 0, 0); font-weight: normal; font-style: normal;"  >0</span><span>;</span>  <span style="color: rgb(127, 0, 85); font-weight: bold; font-style: normal;"  >for</span><span>(</span>i<span>=</span><span style="color: rgb(0, 0, 0); font-weight: normal; font-style: normal;"  >1</span><span>;</span>i<span>&lt;=</span>n<span>;</span>i<span>++)</span><span>{</span>   dis<span>[</span>i<span>]=</span><span style="color: rgb(0, 0, 0); font-weight: normal; font-style: normal;"  >0</span><span>;</span>    <span style="color: rgb(113, 122, 179); font-weight: normal; font-style: normal;"  >//给每个项目最早完成时间赋初值 </span>   <span style="color: rgb(127, 0, 85); font-weight: bold; font-style: normal;"  >if</span><span>(</span>Indegree<span>[</span>i<span>]==</span><span style="color: rgb(0, 0, 0); font-weight: normal; font-style: normal;"  >0</span><span>)</span><span>{</span><span style="color: rgb(113, 122, 179); font-weight: normal; font-style: normal;"  >//没有前置项目的项目可以直接开始了 </span>    Q<span>[</span>H<span>++]=</span>i<span>;</span>   <span>}</span>  <span>}</span>  <span style="color: rgb(127, 0, 85); font-weight: bold; font-style: normal;"  >while</span><span>(</span>L<span>&lt;</span>H<span>)</span><span>{</span> <span style="color: rgb(113, 122, 179); font-weight: normal; font-style: normal;"  >//模拟拓扑排序过程，求出每个项目最早可以开始的时间 </span>   k<span>=</span>Q<span>[</span>L<span>++];</span>   <span style="color: rgb(127, 0, 85); font-weight: bold; font-style: normal;"  >for</span><span>(</span>y<span>=</span><span style="color: rgb(0, 0, 0); font-weight: normal; font-style: normal;"  >1</span><span>;</span>y<span>&lt;=</span>n<span style="color: rgb(0, 0, 0); font-weight: normal; font-style: normal;"  >+1</span><span>;</span>y<span>++)</span>    <span style="color: rgb(127, 0, 85); font-weight: bold; font-style: normal;"  >if</span><span>(</span>map<span>[</span>k<span>][</span>y<span>])</span><span>{</span>     <span style="color: rgb(127, 0, 85); font-weight: bold; font-style: normal;"  >if</span><span>(</span>dis<span>[</span>y<span>]&lt;</span>dis<span>[</span>k<span>]+</span>map<span>[</span>k<span>][</span>y<span>])</span><span style="color: rgb(113, 122, 179); font-weight: normal; font-style: normal;"  >//y的所有前置项目的最晚完成时间作为它最早开始时间 </span>      dis<span>[</span>y<span>]=</span>dis<span>[</span>k<span>]+</span>map<span>[</span>k<span>][</span>y<span>];</span>     Indegree<span>[</span>y<span>]--;</span>     <span style="color: rgb(127, 0, 85); font-weight: bold; font-style: normal;"  >if</span><span>(</span>Indegree<span>[</span>y<span>]==</span><span style="color: rgb(0, 0, 0); font-weight: normal; font-style: normal;"  >0</span><span>)</span><span>{</span><span style="color: rgb(113, 122, 179); font-weight: normal; font-style: normal;"  >//入度为0时，表示它的前置项目都已完成 </span>      Q<span>[</span>H<span>++]=</span>y<span>;</span>     <span>}</span>    <span>}</span>  <span>}</span>  <span style="color: rgb(113, 122, 179); font-weight: normal; font-style: normal;"  >//第n+1个点是虚拟出来的，所有没有后置项目的项目作为它的前置项目 </span>  <span style="color: rgb(113, 122, 179); font-weight: normal; font-style: normal;"  >//当它所有的前置项目都完成时，表示整个项目完成 </span>  <span style="color: rgb(127, 0, 85); font-weight: bold; font-style: normal;"  >return</span> dis<span>[</span>n<span style="color: rgb(0, 0, 0); font-weight: normal; font-style: normal;"  >+1</span><span>];</span> <span>}</span> <span style="color: rgb(127, 0, 85); font-weight: bold; font-style: normal;"  >int</span> <span style="color: rgb(0, 0, 0); font-weight: normal; font-style: normal;"  >main</span><span>()</span><span>{</span>  <span style="color: rgb(127, 0, 85); font-weight: bold; font-style: normal;"  >int</span> n<span>,</span>m<span>,</span>i<span>,</span>j<span>,</span>x<span>,</span>y<span>;</span>   <span style="color: rgb(0, 0, 0); font-weight: normal; font-style: normal;"  >scanf</span><span>(</span><span style="color: rgb(0, 0, 255); font-weight: normal; font-style: normal;"  >"%d %d"</span><span>,&amp;</span>n<span>,&amp;</span>m<span>);</span>   <span style="color: rgb(127, 0, 85); font-weight: bold; font-style: normal;"  >for</span><span>(</span>i<span>=</span><span style="color: rgb(0, 0, 0); font-weight: normal; font-style: normal;"  >1</span><span>;</span>i<span>&lt;=</span>n<span>;</span>i<span>++)</span>    <span style="color: rgb(0, 0, 0); font-weight: normal; font-style: normal;"  >scanf</span><span>(</span><span style="color: rgb(0, 0, 255); font-weight: normal; font-style: normal;"  >"%d"</span><span>,&amp;</span>cost<span>[</span>i<span>]);</span>   <span style="color: rgb(0, 0, 0); font-weight: normal; font-style: normal;"  >memset</span><span>(</span>map<span>,</span><span style="color: rgb(0, 0, 0); font-weight: normal; font-style: normal;"  >0</span><span>,</span><span style="color: rgb(127, 0, 85); font-weight: bold; font-style: normal;"  >sizeof</span><span>(</span>map<span>));</span><span style="color: rgb(113, 122, 179); font-weight: normal; font-style: normal;"  >//存储优先关系 </span>   <span style="color: rgb(0, 0, 0); font-weight: normal; font-style: normal;"  >memset</span><span>(</span>Indegree<span>,</span><span style="color: rgb(0, 0, 0); font-weight: normal; font-style: normal;"  >0</span><span>,</span><span style="color: rgb(127, 0, 85); font-weight: bold; font-style: normal;"  >sizeof</span><span>(</span>Indegree<span>));</span><span style="color: rgb(113, 122, 179); font-weight: normal; font-style: normal;"  >//入度 </span>   <span style="color: rgb(0, 0, 0); font-weight: normal; font-style: normal;"  >memset</span><span>(</span>Outdegree<span>,</span><span style="color: rgb(0, 0, 0); font-weight: normal; font-style: normal;"  >0</span><span>,</span><span style="color: rgb(127, 0, 85); font-weight: bold; font-style: normal;"  >sizeof</span><span>(</span>Outdegree<span>));</span><span style="color: rgb(113, 122, 179); font-weight: normal; font-style: normal;"  >//出度 </span>   <span style="color: rgb(127, 0, 85); font-weight: bold; font-style: normal;"  >while</span><span>(</span>m<span>--&amp;&amp;</span><span style="color: rgb(0, 0, 0); font-weight: normal; font-style: normal;"  >scanf</span><span>(</span><span style="color: rgb(0, 0, 255); font-weight: normal; font-style: normal;"  >"%d %d"</span><span>,&amp;</span>x<span>,&amp;</span>y<span>))</span><span>{</span>    map<span>[</span>x<span>][</span>y<span>]=</span><span style="color: rgb(0, 0, 0); font-weight: normal; font-style: normal;"  >1</span><span>;</span>    Indegree<span>[</span>y<span>]++;</span>    Outdegree<span>[</span>x<span>]++;</span>   <span>}</span>   <span style="color: rgb(127, 0, 85); font-weight: bold; font-style: normal;"  >for</span><span>(</span>i<span>=</span><span style="color: rgb(0, 0, 0); font-weight: normal; font-style: normal;"  >1</span><span>;</span>i<span>&lt;=</span>n<span>;</span>i<span>++)</span>    <span style="color: rgb(127, 0, 85); font-weight: bold; font-style: normal;"  >if</span><span>(</span>Outdegree<span>[</span>i<span>]==</span><span style="color: rgb(0, 0, 0); font-weight: normal; font-style: normal;"  >0</span><span>)</span><span>{</span><span style="color: rgb(113, 122, 179); font-weight: normal; font-style: normal;"  >//没有出度的项目作为第n+1项目的前置项目 </span>     map<span>[</span>i<span>][</span>n<span style="color: rgb(0, 0, 0); font-weight: normal; font-style: normal;"  >+1</span><span>]=</span><span style="color: rgb(0, 0, 0); font-weight: normal; font-style: normal;"  >1</span><span>;</span>     Indegree<span>[</span>n<span style="color: rgb(0, 0, 0); font-weight: normal; font-style: normal;"  >+1</span><span>]++;</span>    <span>}</span>   <span style="color: rgb(127, 0, 85); font-weight: bold; font-style: normal;"  >for</span><span>(</span>i<span>=</span><span style="color: rgb(0, 0, 0); font-weight: normal; font-style: normal;"  >1</span><span>;</span>i<span>&lt;=</span>n<span>;</span>i<span>++)</span>    <span style="color: rgb(127, 0, 85); font-weight: bold; font-style: normal;"  >for</span><span>(</span>j<span>=</span><span style="color: rgb(0, 0, 0); font-weight: normal; font-style: normal;"  >1</span><span>;</span>j<span>&lt;=</span>n<span style="color: rgb(0, 0, 0); font-weight: normal; font-style: normal;"  >+1</span><span>;</span>j<span>++)</span>     <span style="color: rgb(127, 0, 85); font-weight: bold; font-style: normal;"  >if</span><span>(</span>map<span>[</span>i<span>][</span>j<span>])</span>map<span>[</span>i<span>][</span>j<span>]=</span>cost<span>[</span>i<span>];</span><span style="color: rgb(113, 122, 179); font-weight: normal; font-style: normal;"  >//将优先关系的权值赋为前置项目要花费的时间 </span>   <span style="color: rgb(0, 0, 0); font-weight: normal; font-style: normal;"  >printf</span><span>(</span><span style="color: rgb(0, 0, 255); font-weight: normal; font-style: normal;"  >"%d</span><span style="color: rgb(0, 0, 255); font-weight: normal; font-style: normal;"  >\n</span><span style="color: rgb(0, 0, 255); font-weight: normal; font-style: normal;"  >"</span><span>,</span><span style="color: rgb(0, 0, 0); font-weight: normal; font-style: normal;"  >solve</span><span>(</span>n<span>));</span>  <span style="color: rgb(127, 0, 85); font-weight: bold; font-style: normal;"  >return</span> <span style="color: rgb(0, 0, 0); font-weight: normal; font-style: normal;"  >0</span><span>;</span> <span>}</span></pre></span></div><wbr></div>]]></description>
	    <author><![CDATA[long1]]></author>
	    <comments>http://blog.163.com/lfw2565295@126/blog/static/1220051620124193143686</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/lfw2565295@126/blog/static/1220051620124193143686</guid>
    <pubDate>Sat, 19 May 2012 15:14:03 +0800</pubDate>
    <dcterms:modified>2012-05-19T15:14:03+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[UVALive - 5137 Pyramids WordFinal 2011 J 搜索DP]]></title>	
    <link>http://blog.163.com/lfw2565295@126/blog/static/12200516201241803216808</link>
    <description><![CDATA[<div><div><font size="4"  color="#0000ff"  ><b>这题也是去年总决赛遗憾的题，DP可以算结果，但路径很容易错，其实想到后期大部分数字都是有解的，并且路径不是很深，还是DFS好，效率也很高，就是细节还是很多的</b></font></div><div><br></div><div><span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-family: Simsun; line-height: normal; font-size: medium;"  ><div style="text-align: center; font-family: Arial, Helvetica, sans-serif; font-size: 18pt; font-weight: bold; color: blue; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px;"  ><a style="color: blue; text-transform: none; text-decoration: none; " rel="nofollow" href="http://livearchive.onlinejudge.org/index.php?option=com_onlinejudge&amp;Itemid=8&amp;page=show_problem&amp;problem=3138"  >Pyramids</a></div><div style="text-align: center; font-family: Arial, Helvetica, sans-serif; font-size: 12pt;"  ><table align="center"  ><tbody><tr><td><b>Time Limit:</b>&nbsp;3000MS</td><td width="10px"  ></td><td><b>Memory Limit:</b>&nbsp;Unknown</td><td width="10px"  ></td><td><b>64bit IO Format:</b>&nbsp;%lld &amp; %llu</td></tr></table></div><p align="center"  ><font size="3"  color="#333399"  >[<a style="color: blue; text-transform: none; text-decoration: none; " class="login" rel="nofollow" href="http://acm.hust.edu.cn:8080/judge/problem/toSubmit.action?id=19847"  >Submit</a>]&nbsp;&nbsp; [<a style="color: blue; text-transform: none; text-decoration: none; " rel="nofollow" href="http://acm.hust.edu.cn:8080/judge/problem/viewProblem.action?id=19847"  >Go Back</a>]&nbsp;&nbsp; [<a style="color: blue; text-transform: none; text-decoration: none; " rel="nofollow" href="http://acm.hust.edu.cn:8080/judge/problem/status.action?id=19847"  >Status</a>]&nbsp;&nbsp;</font></p><div id="vj_description"  style="font-family: 'times new roman'; display: block;"  ><p style="text-align: left; font-family: Arial, Helvetica, sans-serif; font-size: 18pt; font-weight: bold; color: blue; margin-bottom: 0px;"  >Description</p><div style="background-color: rgb(234, 235, 255); border-top-left-radius: 10px 10px; border-top-right-radius: 10px 10px; border-bottom-right-radius: 10px 10px; border-bottom-left-radius: 10px 10px; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; border-top-style: dotted; border-right-style: dotted; border-bottom-style: dotted; border-left-style: dotted; border-top-width: 2px; border-right-width: 2px; border-bottom-width: 2px; border-left-width: 2px;"  ><span style="float: right;"  ><a style="color: blue; text-transform: none; text-decoration: none; " target="_blank" rel="nofollow" href="http://livearchive.onlinejudge.org/external/51/5137.pdf"  ><img width="100"  height="26"  border="0"  title="Download as PDF"  alt="Download as PDF"  src="http://livearchive.onlinejudge.org/components/com_onlinejudge/images/button_pdf.png"  ></a></span><div style="clear: both;"  ></div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.0001pt; margin-left: 0px;"  >It is not too hard to build a pyramid if you have a lot of identical cubes. On a flat foundation you lay, say,&nbsp;<span>10&nbsp;<tt>x</tt>&nbsp;10</span>&nbsp;cubes in a square. Centered on top of that square you lay a&nbsp;<span>9&nbsp;<tt>x</tt>&nbsp;9</span>&nbsp;square of cubes. Continuing this way you end up with a single cube, which is the top of the pyramid. The height of such a pyramid equals the length of its base, which in this case is 10. We call this a&nbsp;<span>high</span>&nbsp;pyramid.</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.0001pt; margin-left: 0px;"  >If you think that a high pyramid is too steep, you can proceed as follows. On the&nbsp;<span>10&nbsp;<tt>x</tt>&nbsp;10</span>&nbsp;base square, lay an&nbsp;<span>8&nbsp;<tt>x</tt>&nbsp;8</span>&nbsp;square, then a&nbsp;<span>6&nbsp;<tt>x</tt>&nbsp;6</span>&nbsp;square, and so on, ending with a&nbsp;<span>2&nbsp;<tt>x</tt>2</span>&nbsp;top square (if you start with a base of odd length, you end up with a single cube on top, of course). The height of this pyramid is about half the length of its base. We call this a&nbsp;<span>low</span>&nbsp;pyramid.</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.0001pt; margin-left: 0px;"  ></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.0001pt; margin-left: 0px;"  ><br>Once upon a time (quite a long time ago, actually) there was a pharaoh who inherited a large number of stone cubes from his father. He ordered his architect to use all of these cubes to build a pyramid, not leaving a single one unused. The architect kindly explained that not every number of cubes can form a pyramid. With 10 cubes you can build a low pyramid with base 3. With 5 cubes you can build a high pyramid of base 2. But no pyramid can be built using exactly 7 cubes.</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.0001pt; margin-left: 0px;"  >The pharaoh was not amused, but after some thinking he came up with new restrictions.</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.0001pt; margin-left: 0px;"  ></p><ol><li>All cubes must be used.</li><li>You may build more than one pyramid, but you must build as few pyramids as possible.</li><li>All pyramids must be different.</li><li>Each pyramid must have a height of at least 2.</li><li>Satisfying the above, the largest of the pyramids must be as large as possible (i.e., containing the most cubes).</li><li>Satisfying the above, the next-to-largest pyramid must be as large as possible.</li><li>And so on<span>...</span></li></ol><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.0001pt; margin-left: 0px;"  >Drawing figures and pictures in the sand, it took the architect quite some time to come up with the best solution.</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.0001pt; margin-left: 0px;"  >Write a program that determines how to meet the restrictions of the pharaoh, given the number of cubes.</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.0001pt; margin-left: 0px;"  ></p></div></div><div id="vj_input"  style="font-family: 'times new roman'; display: block;"  ><p style="text-align: left; font-family: Arial, Helvetica, sans-serif; font-size: 18pt; font-weight: bold; color: blue; margin-bottom: 0px;"  >Input</p><div style="background-color: rgb(234, 235, 255); border-top-left-radius: 10px 10px; border-top-right-radius: 10px 10px; border-bottom-right-radius: 10px 10px; border-bottom-left-radius: 10px 10px; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; border-top-style: dotted; border-right-style: dotted; border-bottom-style: dotted; border-left-style: dotted; border-top-width: 2px; border-right-width: 2px; border-bottom-width: 2px; border-left-width: 2px;"  ><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.0001pt; margin-left: 0px;"  >The input consists of several test cases, each one on a single line. A test case is an integer&nbsp;<span><i>c</i></span>, where&nbsp;<span>1<img width="18"  height="31"  align="MIDDLE"  border="0"  src="http://livearchive.onlinejudge.org/external/51/5137img1.png"  alt="$ \le$"  ><i>c</i><img width="18"  height="31"  align="MIDDLE"  border="0"  src="http://livearchive.onlinejudge.org/external/51/5137img1.png"  alt="$ \le$"  >10<sup>6</sup></span>, giving the number of cubes available.</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.0001pt; margin-left: 0px;"  >The last test case is followed by a line containing a single zero.</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.0001pt; margin-left: 0px;"  ></p></div></div><div id="vj_output"  style="font-family: 'times new roman'; display: block;"  ><p style="text-align: left; font-family: Arial, Helvetica, sans-serif; font-size: 18pt; font-weight: bold; color: blue; margin-bottom: 0px;"  >Output</p><div style="background-color: rgb(234, 235, 255); border-top-left-radius: 10px 10px; border-top-right-radius: 10px 10px; border-bottom-right-radius: 10px 10px; border-bottom-left-radius: 10px 10px; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; border-top-style: dotted; border-right-style: dotted; border-bottom-style: dotted; border-left-style: dotted; border-top-width: 2px; border-right-width: 2px; border-bottom-width: 2px; border-left-width: 2px;"  ><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.0001pt; margin-left: 0px;"  >For each test case, display its case number followed by the pyramids to be built. The pyramids should be ordered with the largest first. Pyramids are specified by the length of their base followed by an&nbsp;<tt>L</tt>&nbsp;for low pyramids or an&nbsp;<tt>H</tt>&nbsp;for high pyramids. If two different pyramids have the same number of cubes, list the high pyramid first. Print ``<tt>impossible</tt>" if it is not possible to meet the requirements of the pharaoh.</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.0001pt; margin-left: 0px;"  >Follow the format of the sample output.</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.0001pt; margin-left: 0px;"  ></p></div></div><div id="vj_sampleInput"  style="font-family: 'times new roman'; display: block;"  ><p style="text-align: left; font-family: Arial, Helvetica, sans-serif; font-size: 18pt; font-weight: bold; color: blue; margin-bottom: 0px;"  >Sample Input</p><div style="background-color: rgb(234, 235, 255); border-top-left-radius: 10px 10px; border-top-right-radius: 10px 10px; border-bottom-right-radius: 10px 10px; border-bottom-left-radius: 10px 10px; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; border-top-style: dotted; border-right-style: dotted; border-bottom-style: dotted; border-left-style: dotted; border-top-width: 2px; border-right-width: 2px; border-bottom-width: 2px; border-left-width: 2px;"  ><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.0001pt; margin-left: 0px;"  ></p><pre style="white-space: pre-wrap; word-wrap: break-word;"  >29 28 0 </pre><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.0001pt; margin-left: 0px;"  ></p></div></div><div id="vj_sampleOutput"  style="font-family: 'times new roman'; display: block;"  ><p style="text-align: left; font-family: Arial, Helvetica, sans-serif; font-size: 18pt; font-weight: bold; color: blue; margin-bottom: 0px;"  >Sample Output</p><div style="background-color: rgb(234, 235, 255); border-top-left-radius: 10px 10px; border-top-right-radius: 10px 10px; border-bottom-right-radius: 10px 10px; border-bottom-left-radius: 10px 10px; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; border-top-style: dotted; border-right-style: dotted; border-bottom-style: dotted; border-left-style: dotted; border-top-width: 2px; border-right-width: 2px; border-bottom-width: 2px; border-left-width: 2px;"  ><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.0001pt; margin-left: 0px;"  ></p><pre style="white-space: pre-wrap; word-wrap: break-word;"  >Case 1: 3H 3L 2H Case 2: impossible</pre></div></div></span></div><div><br></div><div><br></div><div>/*</div><div>whu isea 李岩的报告&nbsp;</div><div>J题：利用方块来建pyramid，每一层都为N*N的正方形。一种是High的，每层正方形边长递减1，一种是Low的，每层递减2。现在有N (&lt;=10^6) 个方块，所有的都必须使用用来建立最少的pyramid。不能有相同的pyramid。相同个数最少的方案输出最大的包含方块最多的方案，依次定义优先级。输出方案。</div><div>由于平方增长的速度比较快，推测pyramid的种类并不多。用程序简单的跑一下，可以发现不同个数为320。DP的复杂度是够了，三千万，但是别激动，要输出方案。</div><div>比赛中，我很早就开了这个题，甚至有FB的幻想。但是一次又一次的WA的现实浇灭了理想，最终的board上，可以发现很多队伍也被卡在这道题目上很久，一道看上去很直接很老套的背包DP，究竟问题出在哪呢？</div><div>这场比赛我前期的主要精力都消磨在这道题了，而所有的代码实质上是一个错误的DP。这个错误却又一叶障目，让人迟迟走不出来。前面说过，DP的时间复杂度是三千万，直接做的话，空间复杂度也是三千万*数据类型，接近几G的内存要求。这在现场赛虽然是可以的，但是对于大部分时间还是刷OJ的ACMer，显然不够放心。于是试图寻找各种优化方法减小内存，就有了各种形态各异但都是错误方法的DP记录，回溯答案。</div><div>举我自己的错误方法。DP[i]记录i个方块能建立pyramid的最少值，pre[i]记录能转移过来的最小状态，输出N的拆分方案时，每次回溯到pre[n]的状态，保证当前组成的pyramid最大，递归处理。这个空间复杂度确实低，但是问题也很显然，由于输出的方案是pyramid递减的，就会遇到当前状态的pre[i]大于前一个输出的。修补方案，记录当前状态是否可行，如果出现大于的情况，枚举个数，回溯到可行的状态去。听上去挺好了，还是无情的WA。最后哑熊告诉我，DP求的都是错的，我才恍然大悟。</div><div>就不可以直接进行DP转移啊！必须记录当前使用到那一个pyramid，这样才能保证不同这个条件。也就是说，根本就绕不过去，最简单，也是最好的办法就是记录一个bool变量，记录当前方块数使用到某个pyramid是否可行，然后回溯。这道题暴露的问题就是，想问题千万不要想当然，先入为主很可怕，思路清晰严谨才是人间正途。</div><div>值得一提的是，这样写HDOJ还是过不了，虽然我建议刘老师把这个题的内存限制改大了，但由于没算好，128M还是不够用。在这儿通过的唯一方法就是暴搜。加一个最优性剪枝就行，最大的答案也只是6个而已，并且很快就找到了。</div><div>*/&nbsp;</div><div>#include&lt;cstdio&gt;</div><div>#include&lt;cstring&gt;</div><div>#include&lt;iostream&gt;</div><div>#include&lt;algorithm&gt;</div><div>using namespace std;</div><div>const int M=1000000;</div><div>const int N=1000;</div><div>int total[N],h[N],type[N];</div><div>int ind[N]; //命名index竟然编译错误，晕&nbsp;</div><div>int pt;</div><div>int n,limit,step[11];</div><div>bool flag;</div><div>char wd[]={'L','H'};</div><div>//int dp[M+1];</div><div>bool cmp(int a,int b){ //不建结构体，对下标排序&nbsp;</div><div>&nbsp; &nbsp; return total[a]&gt;total[b];</div><div>}</div><div><br></div><div>void init(){</div><div>&nbsp; &nbsp; pt=0;</div><div>&nbsp; &nbsp; for(int i=2; ;i++){</div><div>&nbsp; &nbsp; &nbsp; &nbsp; int val=i*(i+1)*(2*i+1)/6;</div><div><font size="3"  color="#0000ff"  ><b>&nbsp; &nbsp; &nbsp; &nbsp; //total[pt]=total[pt]+i*i; 简单点可以写成这样</b></font></div><div><font size="3"  color="#0000ff"  ><b>&nbsp; &nbsp; &nbsp; &nbsp; //http://blog.163.com/lfw2565295@126/blog/static/122005162012418964333/</b></font></div><div><font size="3"  color="#0000ff"  ><b>&nbsp; &nbsp; &nbsp; &nbsp; //公式推导看我博客，其实挺简单的&nbsp;</b></font></div><div>&nbsp; &nbsp; &nbsp; &nbsp; if(val&gt;=M) break;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; total[pt]=val; h[pt]=i; type[pt]=1;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; pt++;</div><div>&nbsp; &nbsp; }</div><div>&nbsp; &nbsp; for(int i=3; ;i++){</div><div>&nbsp; &nbsp; &nbsp; &nbsp; int val=i*(i+1)*(i+2)/6;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; if(val&gt;=M) break;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; total[pt]=val; h[pt]=i; type[pt]=0;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; pt++;</div><div>&nbsp; &nbsp; }</div><div>&nbsp; &nbsp; for(int i=0; i&lt;pt; i++) ind[i]=i;</div><div>&nbsp; &nbsp; sort(ind,ind+pt,cmp);</div><div>&nbsp; &nbsp; /*for(int i=0; i&lt;pt; i++){</div><div>&nbsp; &nbsp; &nbsp; &nbsp; printf("%d ",total[index[i]]);</div><div>&nbsp; &nbsp; }</div><div>&nbsp; &nbsp; puts("");*/</div><div>&nbsp; &nbsp; /*</div><div>&nbsp; &nbsp; 优化效果不好，基本上都能实现的，DP时间也很费&nbsp;</div><div>&nbsp; &nbsp; printf("pt = %d\n",pt);</div><div>&nbsp; &nbsp; for(int i=0; i&lt;=M; i++) dp[i]=0;</div><div>&nbsp; &nbsp; dp[0]=1;</div><div>&nbsp; &nbsp; int to=0;</div><div>&nbsp; &nbsp; for(int i=0; i&lt;pt; i++){</div><div>&nbsp; &nbsp; &nbsp; &nbsp; for(int j=to; j&gt;=0; j--){</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(dp[j] &amp;&amp; j+total[index[i]]&lt;=M){</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dp[j+total[index[i]]]=1;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; to=max(to, j+total[index[i]]);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; }</div><div>&nbsp; &nbsp; for(int i=0; i&lt;200; i++) if(dp[i]) printf("%d ",i);</div><div>&nbsp; &nbsp; puts("");*/</div><div>}</div><div>bool dfs(int i, int s, int sum){</div><div>&nbsp; &nbsp; //printf("sum= %d %d\n",sum,total[index[i]]);</div><div>&nbsp; &nbsp; if(flag) return true;</div><div>&nbsp; &nbsp; if(sum==n) {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; step[s]=-1;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; flag=true;&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; return true;</div><div>&nbsp; &nbsp; }</div><div>&nbsp; &nbsp; if(sum&gt;n || i==pt || s==limit) return false;</div><div>&nbsp; &nbsp; step[s]=ind[i];</div><div>&nbsp; &nbsp; <b><font color="#0000ff"  size="3"  >dfs(i+1, s+1, sum+total[ind[i]]); //先搜这个，因为基本上上千以上的数字都能搜的到的&nbsp;</font></b></div><div><b><font color="#0000ff"  size="3"  >&nbsp; &nbsp; if(flag) return true; //已经找到了，不要再搜了，不然会覆盖掉step的&nbsp;</font></b></div><div>&nbsp; &nbsp; dfs(i+1, s, sum);</div><div>}</div><div>int main(){</div><div>&nbsp; &nbsp; init();</div><div>&nbsp; &nbsp; int cas=1;</div><div>&nbsp; &nbsp; while(scanf("%d",&amp;n)){</div><div>&nbsp; &nbsp; &nbsp; &nbsp; if(n==0) break;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; printf("Case %d:",cas++);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; flag=false;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; for(int k=1; k&lt;=10; k++){<font size="3"  color="#0000ff"  ><b> //优先还要保证步数最小！！！</b></font>&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; limit=k;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dfs(0,0,0);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(flag) break;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; if(flag){</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(int i=0; ; i++){</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(step[i]==-1) break;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(" %d%c",h[step[i]],wd[type[step[i]]]);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; puts("");</div><div>&nbsp; &nbsp; &nbsp; &nbsp; }else{</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; puts(" impossible");</div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; }</div><div>}</div><div><br></div><wbr></div>]]></description>
	    <author><![CDATA[long1]]></author>
	    <comments>http://blog.163.com/lfw2565295@126/blog/static/12200516201241803216808</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/lfw2565295@126/blog/static/12200516201241803216808</guid>
    <pubDate>Fri, 18 May 2012 12:32:16 +0800</pubDate>
    <dcterms:modified>2012-05-18T12:32:16+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[自然数平方数列和立方数列求和 高次推导低次]]></title>	
    <link>http://blog.163.com/lfw2565295@126/blog/static/122005162012418964333</link>
    <description><![CDATA[<div><div><font size="3"  color="#0000ff"  ><b>1^2+2^2+3^2+……+n^2=n(n+1)(2n+1)/6&nbsp;</b></font></div><div><font size="3"  color="#0000ff"  ><b><br></b></font></div><div><font size="3"  color="#0000ff"  ><b>利用立方差公式</b></font></div><div><font size="3"  color="#0000ff"  ><b>n^3-(n-1)^3=1*[n^2+(n-1)^2+n(n-1)]</b></font></div><div>=n^2+(n-1)^2+n^2-n</div><div>=2*n^2+(n-1)^2-n</div><div><br></div><div>2^3-1^3=2*2^2+1^2-2</div><div>3^3-2^3=2*3^2+2^2-3</div><div>4^3-3^3=2*4^2+3^2-4</div><div>......</div><div>n^3-(n-1)^3=2*n^2+(n-1)^2-n</div><div><br></div><div>各等式全相加</div><div>n^3-1^3=2*(2^2+3^2+...+n^2)+[1^2+2^2+...+(n-1)^2]-(2+3+4+...+n)</div><div><br></div><div>n^3-1=2*(1^2+2^2+3^2+...+n^2)-2+[1^2+2^2+...+(n-1)^2+n^2]-n^2-(2+3+4+...+n)</div><div>&nbsp;</div><div>n^3-1=3*(1^2+2^2+3^2+...+n^2)-2-n^2-(1+2+3+...+n)+1</div><div>&nbsp;</div><div>n^3-1=3(1^2+2^2+...+n^2)-1-n^2-n(n+1)/2</div><div><br></div><div>3(1^2+2^2+...+n^2)=n^3+n^2+n(n+1)/2=(n/2)(2n^2+2n+n+1)</div><div>=(n/2)(n+1)(2n+1)</div><div><br></div><div>1^2+2^2+3^2+...+n^2=n(n+1)(2n+1)/6</div><div><br></div><div><br></div><div><br></div><div><font size="3"  color="#0000ff"  ><b>1^3+2^3+3^3+……+n^3=[n(n+1)/2]^2&nbsp;</b></font></div><div><font size="3"  color="#0000ff"  ><b><br></b></font></div><div><font size="3"  color="#0000ff"  ><b>(n+1)^4-n^4=[(n+1)^2+n^2][(n+1)^2-n^2]</b></font></div><div>=(2n^2+2n+1)(2n+1)</div><div>=4n^3+6n^2+4n+1</div><div><br></div><div>2^4-1^4=4*1^3+6*1^2+4*1+1</div><div>3^4-2^4=4*2^3+6*2^2+4*2+1</div><div>4^4-3^4=4*3^3+6*3^2+4*3+1</div><div>......</div><div>(n+1)^4-n^4=4*n^3+6*n^2+4*n+1</div><div><br></div><div>各式相加有</div><div>(n+1)^4-1=4*(1^3+2^3+3^3...+n^3)+6*(1^2+2^2+...+n^2)+4*(1+2+3+...+n)+n</div><div><br></div><div>4*(1^3+2^3+3^3+...+n^3)=(n+1)^4-1+6*[n(n+1)(2n+1)/6]+4*[(1+n)n/2]+n</div><div>=[n(n+1)]^2&nbsp;</div><div><br></div><div>1^3+2^3+...+n^3=[n(n+1)/2]^2</div><br><div><font size="3"  color="#0000ff"  ><b>1^2+3^2+5^2+...+n^2=n(n+1)(n+2)/6 &nbsp; (n=2*i-1)</b></font></div><div><font size="3"  color="#0000ff"  ><b>2^2+4^2+6^2+...+n^2=n(n+1)(n+2)/6 &nbsp; (n=2*i)</b></font></div><div><font size="3"  color="#0000ff"  ><b><br></b></font></div><div><font size="3"  color="#0000ff"  ><b>推导：</b></font></div><div><pre id="best-answer-content"  style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Arial; white-space: pre-wrap; word-wrap: break-word; zoom: 1; line-height: 22px;"  ><font size="3"  color="#0000ff"  ><b>先要有这个公式</b></font></pre><pre id="best-answer-content"  style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; word-wrap: break-word; zoom: 1;"  ><font color="#0000ff"  face="Arial"  size="3"  ><span style="line-height: 25px; white-space: pre-wrap;"  ><b>1^2+2^2+3^2+4^2+……+n^2=n(n+1)(2n+1)/6 然后把上面的式子变成 1^2+3^2+5^2+………+（2n-1）^2 =[1^2+2^2+3^2+4^2+……+(2n)^2]-[2^2+4^2+6^2+……+(2n)^2] =[1^2+2^2+3^2+4^2+……+(2n)^2]-4*[1^2+2^2+3^2+……+(n)^2] 再用上面的那个公式代入 有 (2n)(2n+1)(4n+1)/6-4*n(n+1)(2n+1)/6 最终得2n(2n-1)(2n+1)/6</b></span></font></pre><pre id="best-answer-content"  style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Arial; white-space: pre-wrap; word-wrap: break-word; zoom: 1; line-height: 22px;"  ><font size="3"  color="#0000ff"  ><b><br></b></font></pre><pre id="best-answer-content"  style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; word-wrap: break-word; zoom: 1;"  ><font face="Arial"  ><span style="white-space: pre-wrap;"  ><br></span></font></pre></div></div>]]></description>
	    <author><![CDATA[long1]]></author>
	    <comments>http://blog.163.com/lfw2565295@126/blog/static/122005162012418964333</comments>
    <slash:comments>2</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/lfw2565295@126/blog/static/122005162012418964333</guid>
    <pubDate>Fri, 18 May 2012 09:06:43 +0800</pubDate>
    <dcterms:modified>2012-05-18T10:19:12+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[UVALive - 5132 Coffee Central WordFinal 2011 E  旋转45度坐标转换]]></title>	
    <link>http://blog.163.com/lfw2565295@126/blog/static/1220051620124173742117</link>
    <description><![CDATA[<div><font size="5"  color="#0000ff"  >这是2011(去年)世界总决赛的E题，当时思路已经有了，坐标变化上卡住了，今天是2012世界总决赛的日子，想来解决下去年遗憾的题</font><wbr><div><a rel="nofollow" href="http://acm.hust.edu.cn:8080/judge/problem/viewProblem.action?id=19842"  >http://acm.hust.edu.cn:8080/judge/problem/viewProblem.action?id=19842</a></div><div><br></div><div><span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-family: Simsun; line-height: normal; font-size: medium;"  ><div style="text-align: center; font-family: Arial, Helvetica, sans-serif; font-size: 18pt; font-weight: bold; color: blue; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px;"  ><a style="color: blue; text-transform: none; text-decoration: none; " rel="nofollow" href="http://livearchive.onlinejudge.org/index.php?option=com_onlinejudge&amp;Itemid=8&amp;page=show_problem&amp;problem=3133"  >Coffee Central</a></div><div style="text-align: center; font-family: Arial, Helvetica, sans-serif; font-size: 12pt;"  ><table align="center"  ><tbody><tr><td><b>Time Limit:</b>&nbsp;5000MS</td><td width="10px"  ></td><td><b>Memory Limit:</b>&nbsp;Unknown</td><td width="10px"  ></td><td><b>64bit IO Format:</b>&nbsp;%lld &amp; %llu</td></tr></table></div><p align="center"  ><font size="3"  color="#333399"  >[<a style="color: blue; text-transform: none; text-decoration: none; " class="login" rel="nofollow" href="http://acm.hust.edu.cn:8080/judge/problem/toSubmit.action?id=19842"  >Submit</a>]&nbsp;&nbsp; [<a style="color: blue; text-transform: none; text-decoration: none; " rel="nofollow" href="http://acm.hust.edu.cn:8080/judge/problem/viewProblem.action?id=19842"  >Go Back</a>]&nbsp;&nbsp; [<a style="color: blue; text-transform: none; text-decoration: none; " rel="nofollow" href="http://acm.hust.edu.cn:8080/judge/problem/status.action?id=19842"  >Status</a>]&nbsp;&nbsp;</font></p><div id="vj_description"  style="font-family: 'times new roman'; display: block;"  ><p style="text-align: left; font-family: Arial, Helvetica, sans-serif; font-size: 18pt; font-weight: bold; color: blue; margin-bottom: 0px;"  >Description</p><div style="background-color: rgb(234, 235, 255); border-top-left-radius: 10px 10px; border-top-right-radius: 10px 10px; border-bottom-right-radius: 10px 10px; border-bottom-left-radius: 10px 10px; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; border-top-style: dotted; border-right-style: dotted; border-bottom-style: dotted; border-left-style: dotted; border-top-width: 2px; border-right-width: 2px; border-bottom-width: 2px; border-left-width: 2px;"  ><span style="float: right;"  ><a style="color: blue; text-transform: none; text-decoration: none; " target="_blank" rel="nofollow" href="http://livearchive.onlinejudge.org/external/51/5132.pdf"  ><img width="100"  height="26"  border="0"  title="Download as PDF"  alt="Download as PDF"  src="http://livearchive.onlinejudge.org/components/com_onlinejudge/images/button_pdf.png"  ></a></span><div style="clear: both;"  ></div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.0001pt; margin-left: 0px;"  >Is it just a fad or is it here to stay? You're not sure, but the steadily increasing number of coffee shops that are opening in your hometown has certainly become quite a draw. Apparently, people have become so addicted to coffee that apartments that are close to many coffee shops will actually fetch higher rents.</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.0001pt; margin-left: 0px;"  >This has come to the attention of a local real-estate company. They are interested in identifying the most valuable locations in the city in terms of their proximity to large numbers of coffee shops. They have given you a map of the city, marked with the locations of coffee shops. Assuming that the average person is willing to walk only a fixed number of blocks for their morning coffee, you have to find the location from which one can reach the largest number of coffee shops. As you are probably aware, your hometown is built on a square grid layout, with blocks aligned on north-south and east-west axes. Since you have to walk along streets, the distance between intersections<span>(<i>a</i>,&nbsp;<i>b</i>)</span>&nbsp;and&nbsp;<span>(<i>c</i>,&nbsp;<i>d</i>&nbsp;)</span>&nbsp;is&nbsp;<span>|&nbsp;<i>a</i>&nbsp;-&nbsp;<i>c</i>| + |&nbsp;<i>b</i>&nbsp;-&nbsp;<i>d</i>|</span>.</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.0001pt; margin-left: 0px;"  ></p></div></div><div id="vj_input"  style="font-family: 'times new roman'; display: block;"  ><p style="text-align: left; font-family: Arial, Helvetica, sans-serif; font-size: 18pt; font-weight: bold; color: blue; margin-bottom: 0px;"  >Input</p><div style="background-color: rgb(234, 235, 255); border-top-left-radius: 10px 10px; border-top-right-radius: 10px 10px; border-bottom-right-radius: 10px 10px; border-bottom-left-radius: 10px 10px; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; border-top-style: dotted; border-right-style: dotted; border-bottom-style: dotted; border-left-style: dotted; border-top-width: 2px; border-right-width: 2px; border-bottom-width: 2px; border-left-width: 2px;"  ><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.0001pt; margin-left: 0px;"  >The input contains several test cases. Each test case describes a city. The first line of each test case contains four integers&nbsp;<span><i>dx</i></span>,&nbsp;<span><i>dy</i></span>,&nbsp;<span><i>n</i></span>, and&nbsp;<span><i>q</i></span>. These are the dimensions of the city grid&nbsp;<span><i>dx</i>&nbsp;<tt>x</tt>&nbsp;<i>dy</i></span>&nbsp;<span>(1<img width="18"  height="31"  align="MIDDLE"  border="0"  src="http://livearchive.onlinejudge.org/external/51/5132img1.png"  alt="$ \le$"  ><i>dx</i>,&nbsp;<i>dy</i><img width="18"  height="31"  align="MIDDLE"  border="0"  src="http://livearchive.onlinejudge.org/external/51/5132img1.png"  alt="$ \le$"  >1000)</span>, the number of coffee shops&nbsp;<span><i>n</i></span>&nbsp;<span>(0<img width="18"  height="31"  align="MIDDLE"  border="0"  src="http://livearchive.onlinejudge.org/external/51/5132img1.png"  alt="$ \le$"  ><i>n</i><img width="18"  height="31"  align="MIDDLE"  border="0"  src="http://livearchive.onlinejudge.org/external/51/5132img1.png"  alt="$ \le$"  >5<sup>&nbsp;.&nbsp;</sup>10<sup>5</sup>)</span>, and the number of queries&nbsp;<span><i>q</i></span>&nbsp;<span>(1<img width="18"  height="31"  align="MIDDLE"  border="0"  src="http://livearchive.onlinejudge.org/external/51/5132img1.png"  alt="$ \le$"  ><i>q</i><img width="18"  height="31"  align="MIDDLE"  border="0"  src="http://livearchive.onlinejudge.org/external/51/5132img1.png"  alt="$ \le$"  >20)</span>. Each of the next&nbsp;<span><i>n</i></span>&nbsp;lines contains two integers&nbsp;<span><i>x</i><sub>i</sub></span>&nbsp;and&nbsp;<span><i>y</i><sub>i</sub></span>&nbsp;<span>(1<img width="18"  height="31"  align="MIDDLE"  border="0"  src="http://livearchive.onlinejudge.org/external/51/5132img1.png"  alt="$ \le$"  ><i>x</i><sub>i</sub><img width="18"  height="31"  align="MIDDLE"  border="0"  src="http://livearchive.onlinejudge.org/external/51/5132img1.png"  alt="$ \le$"  ><i>dx</i>, 1<img width="18"  height="31"  align="MIDDLE"  border="0"  src="http://livearchive.onlinejudge.org/external/51/5132img1.png"  alt="$ \le$"  ><i>y</i><sub>i</sub><img width="18"  height="31"  align="MIDDLE"  border="0"  src="http://livearchive.onlinejudge.org/external/51/5132img1.png"  alt="$ \le$"  ><i>dy</i>)</span>; these specify the location of the&nbsp;<span><i>i</i></span>-th coffee shop. There will be at most one coffee shop per intersection. Each of the next&nbsp;<span><i>q</i></span>lines contains a single integer&nbsp;<span><i>m</i></span>&nbsp;<span>(0<img width="18"  height="31"  align="MIDDLE"  border="0"  src="http://livearchive.onlinejudge.org/external/51/5132img1.png"  alt="$ \le$"  ><i>m</i><img width="18"  height="31"  align="MIDDLE"  border="0"  src="http://livearchive.onlinejudge.org/external/51/5132img1.png"  alt="$ \le$"  >10<sup>6</sup>)</span>, the maximal distance that a person is willing to walk for a cup of coffee.</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.0001pt; margin-left: 0px;"  >The last test case is followed by a line containing four zeros.</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.0001pt; margin-left: 0px;"  ></p></div></div><div id="vj_output"  style="font-family: 'times new roman'; display: block;"  ><p style="text-align: left; font-family: Arial, Helvetica, sans-serif; font-size: 18pt; font-weight: bold; color: blue; margin-bottom: 0px;"  >Output</p><div style="background-color: rgb(234, 235, 255); border-top-left-radius: 10px 10px; border-top-right-radius: 10px 10px; border-bottom-right-radius: 10px 10px; border-bottom-left-radius: 10px 10px; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; border-top-style: dotted; border-right-style: dotted; border-bottom-style: dotted; border-left-style: dotted; border-top-width: 2px; border-right-width: 2px; border-bottom-width: 2px; border-left-width: 2px;"  ><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.0001pt; margin-left: 0px;"  >For each test case in the input, display its case number. Then display one line per query in the test case. Each line displays the maximum number of coffee shops reachable for the given query distance&nbsp;<span><i>m</i></span>&nbsp;followed by the optimal location. For example, the sample output shows that 3 coffee shops are within query distance 1 of the optimal location (3, 4), 4 shops are within query distance 2 of optimal location (2, 2), and 5 shops are within query distance 4 of optimal location (3, 1). If there are multiple optimal locations, pick the location that is furthest south (minimal positive integer&nbsp;<span><i>y</i></span>-coordinate). If there is still a tie, pick the location furthest west (minimal positive integer&nbsp;<span><i>x</i></span>-coordinate).</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.0001pt; margin-left: 0px;"  >Follow the format of the sample output.</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.0001pt; margin-left: 0px;"  ></p></div></div><div id="vj_sampleInput"  style="font-family: 'times new roman'; display: block;"  ><p style="text-align: left; font-family: Arial, Helvetica, sans-serif; font-size: 18pt; font-weight: bold; color: blue; margin-bottom: 0px;"  >Sample Input</p><div style="background-color: rgb(234, 235, 255); border-top-left-radius: 10px 10px; border-top-right-radius: 10px 10px; border-bottom-right-radius: 10px 10px; border-bottom-left-radius: 10px 10px; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; border-top-style: dotted; border-right-style: dotted; border-bottom-style: dotted; border-left-style: dotted; border-top-width: 2px; border-right-width: 2px; border-bottom-width: 2px; border-left-width: 2px;"  ><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.0001pt; margin-left: 0px;"  ></p><pre style="white-space: pre-wrap; word-wrap: break-word;"  >4 4 5 3 1 1 1 2 3 3 4 4 2 4 1 2  4 0 0 0 0 </pre><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.0001pt; margin-left: 0px;"  ></p></div></div><div id="vj_sampleOutput"  style="font-family: 'times new roman'; display: block;"  ><p style="text-align: left; font-family: Arial, Helvetica, sans-serif; font-size: 18pt; font-weight: bold; color: blue; margin-bottom: 0px;"  >Sample Output</p><div style="background-color: rgb(234, 235, 255); border-top-left-radius: 10px 10px; border-top-right-radius: 10px 10px; border-bottom-right-radius: 10px 10px; border-bottom-left-radius: 10px 10px; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; border-top-style: dotted; border-right-style: dotted; border-bottom-style: dotted; border-left-style: dotted; border-top-width: 2px; border-right-width: 2px; border-bottom-width: 2px; border-left-width: 2px;"  ><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.0001pt; margin-left: 0px;"  ></p><pre style="white-space: pre-wrap; word-wrap: break-word;"  >Case 1: 3 (3,4) 4 (2,2) 5 (3,1)</pre></div></div></span></div><div><br></div><div><div>#include&lt;cstdio&gt;</div><div>#include&lt;cstring&gt;</div><div>#include&lt;iostream&gt;</div><div>using namespace std;</div><div>#define mp make_pair</div><div>const int M=2000;</div><div>int f[M][M];</div><div>int dx,dy,n,m,dxy;</div><div><b><font color="#0000ff"  >//dxy表示把原来的矩形当成正方形，即空余部分当成不影响的点，dxy=max(dx,dy)&nbsp;</font></b></div><div><b><font color="#0000ff"  >//当成正方形的话，旋转后的形状很容易识别&nbsp;</font></b></div><div><b><font color="#0000ff"  >//坐标变化的话，有向上旋转45度，向下旋转45度，刚好x,y变化方式相反</font></b></div><div><b><font color="#0000ff"  >//反过来推导就可以用二元一次方程组了，具体转换方式见下&nbsp;</font></b></div><div><b><font color="#0000ff"  >int X,Y;</font></b></div><div><b><font color="#0000ff"  >//X,Y表示原来的正方形旋转45度后，新的边长,X=Y=dxy*2-1</font></b>&nbsp;</div><div>pair&lt; int, pair&lt;int,int&gt; &gt; res;</div><div><font color="#0000ff"  size="4"  ><b>int newx(int x,int y){ //向下45度，x坐标转化&nbsp;</b></font></div><div><font color="#0000ff"  size="4"  ><b>&nbsp; &nbsp; return x+y-1;</b></font></div><div><font color="#0000ff"  size="4"  ><b>}</b></font></div><div><font color="#0000ff"  size="4"  ><b>int newy(int x,int y){ //向下45度，y坐标转化&nbsp;</b></font></div><div><font color="#0000ff"  size="4"  ><b>&nbsp; &nbsp; return y-x+dxy;</b></font></div><div><font color="#0000ff"  size="4"  ><b>}</b></font></div><div>int calc(int x,int y,int dis){</div><div>&nbsp; &nbsp; int minx=max(1,x-dis);</div><div>&nbsp; &nbsp; int maxx=min(X,x+dis);</div><div>&nbsp; &nbsp; int miny=max(1,y-dis);</div><div>&nbsp; &nbsp; int maxy=min(Y,y+dis);</div><div>&nbsp; &nbsp; return f[maxx][maxy]-f[maxx][miny-1]-f[minx-1][maxy]+f[minx-1][miny-1];</div><div>}</div><div>void solve(int dis){</div><div>&nbsp; &nbsp; res=mp(0, mp(1 , 1) );</div><div>&nbsp; &nbsp; for(int i=1; i&lt;=dx; i++){</div><div>&nbsp; &nbsp; &nbsp; &nbsp; for(int j=1; j&lt;=dy; j++){</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int x=newx(i,j);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int y=newy(i,j);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int cnt=calc(x,y,dis);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(cnt&gt;res.first) res=mp(cnt, mp(i,j));</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if(cnt==res.first &amp;&amp; (j&lt;res.second.second || (j==res.second.second &amp;&amp; i&lt;res.second.first)))&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; res=mp(cnt, mp(i,j));</div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; }</div><div>}</div><div>int main(){</div><div>&nbsp; &nbsp; int cas=1;</div><div>&nbsp; &nbsp; while(scanf("%d%d%d%d",&amp;dx,&amp;dy,&amp;n,&amp;m)){</div><div>&nbsp; &nbsp; &nbsp; &nbsp; if(dx==0 &amp;&amp; dy==0 &amp;&amp; n==0 &amp;&amp; m==0) break;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; dxy=max(dx,dy);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; X=Y=dxy*2-1;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; for(int i=0; i&lt;=X; i++){</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(int j=0; j&lt;=Y; j++) f[i][j]=0;&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; for(int i=0; i&lt;n; i++){</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int a,b;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scanf("%d%d",&amp;a,&amp;b);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int x=newx(a,b);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int y=newy(a,b);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; f[x][y]=1;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; for(int i=1; i&lt;=X; i++){</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(int j=1; j&lt;=Y; j++){</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; f[i][j]+=f[i-1][j]+f[i][j-1]-f[i-1][j-1];</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; printf("Case %d:\n",cas++);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; while(m--){</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int dis;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scanf("%d",&amp;dis);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; solve(dis);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf("%d (%d,%d)\n",res.first, res.second.first, res.second.second);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; }</div><div>}</div></div><div><br></div><div><font size="3"  color="#0000ff"  ><b>把之前的矩形，短边补长，变成正方形后，会好像的多，旋转后，可以模拟小规模数据，比如3*3的正方形，想象旋转45度后</b></font></div><div><font size="3"  color="#0000ff"  ><b>(1,1) -&gt; (1,3)</b></font></div><div><font size="3"  color="#0000ff"  ><b>(1,2) -&gt; (2,4)</b></font></div><div><font size="3"  color="#0000ff"  ><b>(1,3) -&gt; (3,5)</b></font></div><div><font size="3"  color="#0000ff"  ><b>(2,1) -&gt; (2,2)</b></font></div><div><font size="3"  color="#0000ff"  ><b>(2,2) -&gt; (3,3)</b></font></div><div><font size="3"  color="#0000ff"  ><b>(2,3) -&gt; (4,4)</b></font></div><div><font size="3"  color="#0000ff"  ><b>(3,1) -&gt; (3,1)</b></font></div><div><font size="3"  color="#0000ff"  ><b>(3,2) -&gt; (4,2)</b></font></div><div><font size="3"  color="#0000ff"  ><b>(3,3) -&gt; (5,3)</b></font></div><div><font size="3"  color="#0000ff"  ><b>然后容易得出结论: newx=x+y-1 &nbsp; newy=y-x+dxy (dxy为正方形边长=3)</b></font></div><div><font size="3"  color="#0000ff"  ><b>不管向上旋转45度还是向下旋转45度，对结果不影响，只要枚举一个位置坐标，然后看以这个位置坐标距离m范围内的矩形有多少个咖啡店就可以了</b></font></div><div><font size="3"  color="#0000ff"  ><b>统计矩形内咖啡店个数就是经典的矩形统计DP了：</b></font></div><div><font size="3"  color="#0000ff"  ><b>&nbsp; &nbsp; return f[maxx][maxy]-f[maxx][miny-1]-f[minx-1][maxy]+f[minx-1][miny-1];</b></font></div><div><font size="3"  color="#0000ff"  ><b>所以整道题其实不是很难，转换坐标是关键部分</b></font></div></div>]]></description>
	    <author><![CDATA[long1]]></author>
	    <comments>http://blog.163.com/lfw2565295@126/blog/static/1220051620124173742117</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/lfw2565295@126/blog/static/1220051620124173742117</guid>
    <pubDate>Thu, 17 May 2012 15:13:08 +0800</pubDate>
    <dcterms:modified>2012-05-17T15:13:08+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[shell编程练习2]]></title>	
    <link>http://blog.163.com/lfw2565295@126/blog/static/1220051620124168252055</link>
    <description><![CDATA[<div><div><font size="4"  color="#0000ff"  ><b>练习循环</b></font></div><div><font size="4"  color="#0000ff"  ><b>for; while; break 2; continue;</b></font></div><div><br></div><div>makedir.sh:</div><div><br></div><div>#! /bin/bash</div><div><br></div><div>mkdir -p ~/桌面/dir</div><div>for i in 1 2 3 4 5</div><div>do</div><div>&nbsp; mkdir -p ~/桌面/dir/mydir${i}</div><div><font size="4"  color="#0000ff"  ><b>&nbsp; if [ $? -eq 0 ] ; then #$?返回上一条命令的返回值 如果是0表示成功退出</b></font></div><div>&nbsp; &nbsp; echo "创建mydir${i}成功"</div><div>&nbsp; &nbsp; continue</div><div>&nbsp; else</div><div>&nbsp; &nbsp; echo "串建mydir${i}失败"</div><div>&nbsp; fi</div><div>done</div><div><br></div><div>long1lfw@ubuntu:~/桌面$ vim makedir.sh</div><div>long1lfw@ubuntu:~/桌面$ chmod +x makedir.sh</div><div>long1lfw@ubuntu:~/桌面$ ./makedir.sh&nbsp;</div><div>创建mydir1成功</div><div>创建mydir2成功</div><div>创建mydir3成功</div><div>创建mydir4成功</div><div>创建mydir5成功</div><div>这样，桌面上就串建了一个dir文件夹，里面有mydir{1 2 3 4 5}五个文件夹，分别在这些文件夹里随便建一些 doc; c; sh; 文件</div><div><br></div><div>然后写个备份功能的shell</div><div>cpdir.sh：</div><div>#! /bin/bash</div><div><br></div><div>mkdir -p ~/桌面/backup</div><div>i=1</div><div>while [ $i -le 5 ]</div><div>do</div><div>&nbsp; mkdir -p ~/桌面/backup/md${i}</div><div>&nbsp; if [ $? -eq 0 ] ; then</div><div>&nbsp; &nbsp; for j in doc c sh</div><div>&nbsp; &nbsp; do&nbsp;</div><div>&nbsp; &nbsp; &nbsp; cp ~/桌面/dir/mydir${i}/*.${j} ~/桌面/backup/md${i}</div><div>&nbsp; &nbsp; &nbsp; if [ $? -ne 0 ] ; then continue ; fi ;</div><div>&nbsp; &nbsp; done</div><div>&nbsp; else</div><div>&nbsp; &nbsp; echo "不能串建文件夹"</div><div>&nbsp; fi</div><div>&nbsp; i=$(($i+1))</div><div>done</div><div><br></div><div>注意while里i需要$i； for里倒直接可以i;&nbsp;</div><div><font size="4"  color="#0000ff"  ><b>上面如果break 2; 的话：</b></font></div><div><font size="4"  color="#0000ff"  ><b>long1lfw@ubuntu:~/桌面$ ./cpdir.sh&nbsp;</b></font></div><div><font size="4"  color="#0000ff"  ><b>cp: 无法 stat “/home/long1lfw/桌面/dir/mydir2/*.doc”: 没有那个文件或目录</b></font></div><div><font size="4"  color="#0000ff"  ><b>一旦找不到*.${j} 类型的文件，就跳出了</b></font></div><div><font size="4"  color="#0000ff"  ><b><br></b></font></div><div><font size="4"  color="#0000ff"  ><b>break命令接受一个整型参数，大于等于1的整数，标记着退出循环的层数。</b></font></div><div><br></div><div>如果是continue的话，会报错，但继续复制：</div><div>long1lfw@ubuntu:~/桌面$ ./cpdir.sh&nbsp;</div><div>cp: 无法 stat “/home/long1lfw/桌面/dir/mydir2/*.doc”: 没有那个文件或目录</div><div>cp: 无法 stat “/home/long1lfw/桌面/dir/mydir3/*.sh”: 没有那个文件或目录</div><div>cp: 无法 stat “/home/long1lfw/桌面/dir/mydir4/*.doc”: 没有那个文件或目录</div><div>cp: 无法 stat “/home/long1lfw/桌面/dir/mydir4/*.c”: 没有那个文件或目录</div><div>cp: 无法 stat “/home/long1lfw/桌面/dir/mydir4/*.sh”: 没有那个文件或目录</div><div>cp: 无法 stat “/home/long1lfw/桌面/dir/mydir5/*.doc”: 没有那个文件或目录</div><div><br></div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >(long1&nbsp;vs&nbsp;longpo&nbsp;转载请注明出处：</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px;"  ><a style="color: rgb(80, 80, 80); text-decoration: none; " href="http://blog.163.com/lfw2565295@126"  ><span style="line-height: 25px; color: rgb(0, 0, 255); text-decoration: underline; font-size: 10.5pt; font-family: 宋体;"  >http://blog.163.com/lfw2565295@126</span></a></span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >)</span></div><div><font size="4"  color="#0000ff"  ><b>输出数字玩玩：</b></font></div><div>digit.sh:</div><div>#! /bin/bash</div><div>x=0</div><div>while [ $x -lt 10 ]</div><div>do</div><div>&nbsp; y=0</div><div>&nbsp; x=$(($x+1))</div><div>&nbsp; while [ $y -lt $x ]&nbsp;</div><div>&nbsp; do</div><div>&nbsp; &nbsp; echo -e "$y \c" # echo -e 才能使得\c \n有效</div><div>&nbsp; &nbsp; y=$(($y+1))</div><div>&nbsp; done</div><div>&nbsp; echo</div><div>done</div><div><br></div><div>long1lfw@ubuntu:~/桌面$ vim digit.sh</div><div>long1lfw@ubuntu:~/桌面$ chmod +x digit.sh</div><div>long1lfw@ubuntu:~/桌面$ ./digit.s</div><div>0&nbsp;</div><div>0 1&nbsp;</div><div>0 1 2&nbsp;</div><div>0 1 2 3&nbsp;</div><div>0 1 2 3 4&nbsp;</div><div>0 1 2 3 4 5&nbsp;</div><div>0 1 2 3 4 5 6&nbsp;</div><div>0 1 2 3 4 5 6 7&nbsp;</div><div>0 1 2 3 4 5 6 7 8&nbsp;</div><div>0 1 2 3 4 5 6 7 8 9</div><div><font size="4"  color="#0000ff"  ><b>注意： &nbsp;bash里 echo -e 才能使得\c \n 等有效</b></font></div><div><font size="4"  color="#0000ff"  ><b>echo -e &nbsp;后一般会接参数,</b></font></div><div><font size="4"  color="#0000ff"  ><b>-e 若参数出现以下字符，则特别加以处理，而不会将它当成一般</b></font></div><div>文字输出：</div><div>&nbsp; &nbsp;\a 发出警告声；</div><div>&nbsp; &nbsp;\b 删除前一个字符；</div><div>&nbsp; &nbsp;\c 最后不加上换行符号；</div><div>&nbsp; &nbsp;\f 换行但光标仍旧停留在原来的位置；</div><div>&nbsp; &nbsp;\n 换行且光标移至行首；</div><div>&nbsp; &nbsp;\r 光标移至行首，但不换行；</div><div>&nbsp; &nbsp;\t 插入tab；</div><div>&nbsp; &nbsp;\v 与\f相同；</div><div>&nbsp; &nbsp;\\ 插入\字符；</div><div>&nbsp; &nbsp;\nnn 插入nnn（八进制）所代表的ASCII字符；</div><div>echo 语法：echo [-ne][字符串]或 echo [--help][--version]</div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >(long1&nbsp;vs&nbsp;longpo&nbsp;转载请注明出处：</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px;"  ><a style="color: rgb(80, 80, 80); text-decoration: none; " href="http://blog.163.com/lfw2565295@126"  ><span style="line-height: 25px; color: rgb(0, 0, 255); text-decoration: underline; font-size: 10.5pt; font-family: 宋体;"  >http://blog.163.com/lfw2565295@126</span></a></span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >)</span></div><wbr></div>]]></description>
	    <author><![CDATA[long1]]></author>
	    <comments>http://blog.163.com/lfw2565295@126/blog/static/1220051620124168252055</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/lfw2565295@126/blog/static/1220051620124168252055</guid>
    <pubDate>Wed, 16 May 2012 20:25:20 +0800</pubDate>
    <dcterms:modified>2012-05-16T20:25:20+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[SRM541 DIV2 250 500 1000的题 模拟 枚举最小时间 BFS java.util.Queue]]></title>	
    <link>http://blog.163.com/lfw2565295@126/blog/static/122005162012415102114769</link>
    <description><![CDATA[<div><div><font size="4"  color="#0000ff"  ><b>//250</b></font></div><div><font size="4"  color="#0000ff"  ><b>//枚举一个中间串，在后半部分也存在，并且他们前后，以及之间非空</b></font></div><div>import java.util.*;</div><div>import java.util.regex.*;</div><div>import java.text.*;</div><div>import java.math.*;</div><div><br></div><div><br></div><div>public class AkariDaisukiDiv2</div><div>{</div><div><span style="white-space:pre;"  > </span>public int countTuples(String S)</div><div><span style="white-space:pre;"  > </span>{</div><div><span style="white-space:pre;"  >  </span>int res=0;</div><div><span style="white-space:pre;"  >  </span>int n=S.length();</div><div><span style="white-space:pre;"  >  </span>for(int i=1; i&lt;n; i++){</div><div><span style="white-space:pre;"  >   </span>for(int j=i+1; j&lt;n; j++){</div><div><span style="white-space:pre;"  >    </span>String x=S.substring(i, j); //j点不到达的</div><div><span style="white-space:pre;"  >    </span>for(int k=j+1; k&lt;n; k++){</div><div><span style="white-space:pre;"  >     </span>int posK=S.indexOf(x,k); //存在posK为子串的第一个位置，不存在posK==0</div><div><span style="white-space:pre;"  >     </span>if(posK&gt;0 &amp;&amp; posK+x.length()&lt;n){</div><div><span style="white-space:pre;"  >      </span>res++;</div><div><span style="white-space:pre;"  >      </span>k=posK;</div><div><span style="white-space:pre;"  >     </span>}</div><div><span style="white-space:pre;"  >    </span>}</div><div><span style="white-space:pre;"  >   </span>}</div><div><span style="white-space:pre;"  >  </span>}</div><div><span style="white-space:pre;"  >  </span>return res;</div><div><span style="white-space:pre;"  > </span>}</div><div>}</div><div>//Powered by KawigiEdit 2.1.4 (beta) modified by pivanof!</div><div><br></div><div><font size="4"  color="#0000ff"  ><b><br></b></font></div><div><font size="4"  color="#0000ff"  ><b>//500</b></font></div><div><font size="4"  color="#0000ff"  ><b>//两两枚举可能有错，因为有些已经相遇消失了，不会再与其他相遇了</b></font></div><div><font size="4"  color="#0000ff"  ><b>//最好是枚举步数，相遇的最小时间可能是0.5，也就是相距1的两个面对面行走</b></font></div><div><font size="4"  color="#0000ff"  ><b>//所以一开始乘以2，最小时间就变为1了，然后枚举步数</b></font></div><div><font size="4"  color="#0000ff"  ><b>//相遇肯定在图内相遇，遍历图最多2000*2步</b></font></div><div>import java.util.*;</div><div>import java.util.regex.*;</div><div>import java.text.*;</div><div>import java.math.*;</div><div><br></div><div><br></div><div>public class AntsMeet</div><div>{</div><div><span style="white-space:pre;"  > </span>public int countAnts(int[] x, int[] y, String direction)</div><div><span style="white-space:pre;"  > </span>{</div><div><span style="white-space:pre;"  >  </span>int n=x.length;</div><div><span style="white-space:pre;"  >  </span>int[] dx=new int[n];</div><div><span style="white-space:pre;"  >  </span>int[] dy=new int[n];</div><div><span style="white-space:pre;"  >  </span>for(int i=0; i&lt;n; i++){</div><div><span style="white-space:pre;"  >   </span>dx[i]=dy[i]=0;</div><div><span style="white-space:pre;"  >  </span>}</div><div><span style="white-space:pre;"  >  </span>for(int i=0; i&lt;n; i++){</div><div><span style="white-space:pre;"  >   </span>x[i]*=2;</div><div><span style="white-space:pre;"  >   </span>y[i]*=2; //同时扩大两倍，相遇的最小时间单位就变成1了</div><div><span style="white-space:pre;"  >   </span>switch(direction.charAt(i)){</div><div><span style="white-space:pre;"  >    </span>case'N': dy[i]=1; break;</div><div><span style="white-space:pre;"  >    </span>case'E': dx[i]=1; break;</div><div><span style="white-space:pre;"  >    </span>case'S': dy[i]=-1; break;</div><div><span style="white-space:pre;"  >    </span>case'W': dx[i]=-1; break;</div><div><span style="white-space:pre;"  >   </span>}</div><div><span style="white-space:pre;"  >  </span>}</div><div><span style="white-space:pre;"  >  </span>boolean[] chk=new boolean[n];</div><div><span style="white-space:pre;"  >  </span>for(int i=0; i&lt;n; i++) chk[i]=false;</div><div><span style="white-space:pre;"  >  </span>for(int i=0; i&lt;=4000; i++){ //整张图最多2000*2个时刻能跑完，相遇肯定在图内</div><div><span style="white-space:pre;"  >   </span>for(int j=0; j&lt;n; j++){</div><div><span style="white-space:pre;"  >    </span>if(chk[j]) continue;</div><div><span style="white-space:pre;"  >    </span>x[j]+=dx[j];</div><div><span style="white-space:pre;"  >    </span>y[j]+=dy[j];</div><div><span style="white-space:pre;"  >   </span>}</div><div><span style="white-space:pre;"  >   </span>for(int j=0; j&lt;n; j++){</div><div><span style="white-space:pre;"  >    </span>if(chk[j]) continue;</div><div><span style="white-space:pre;"  >    </span>for(int k=j+1; k&lt;n; k++){</div><div><span style="white-space:pre;"  >     </span>if(!chk[k] &amp;&amp; x[j]==x[k] &amp;&amp; y[j]==y[k]){</div><div><span style="white-space:pre;"  >      </span>chk[j]=true;</div><div><span style="white-space:pre;"  >      </span>chk[k]=true;</div><div><span style="white-space:pre;"  >     </span>}</div><div><span style="white-space:pre;"  >    </span>}</div><div><span style="white-space:pre;"  >   </span>}</div><div><span style="white-space:pre;"  >  </span>}</div><div><span style="white-space:pre;"  >  </span>int res=0;</div><div><span style="white-space:pre;"  >  </span>for(boolean a: chk){</div><div><span style="white-space:pre;"  >   </span>if(a==false) res++;</div><div><span style="white-space:pre;"  >  </span>}</div><div><span style="white-space:pre;"  >  </span>return res;</div><div><span style="white-space:pre;"  > </span>}</div><div>}</div><div>//Powered by KawigiEdit 2.1.4 (beta) modified by pivanof!</div><div><br></div><div><font size="4"  color="#0000ff"  ><b>//1000</b></font></div><div><font size="4"  color="#0000ff"  ><b>//规模在4000*4000以内，直接宽搜，已经存在的点直接放入队列，然后四个方向扩展</b></font></div><div><font size="4"  color="#0000ff"  ><b>//用数组判重，用到了java的Queue的offer和poll, 以及LinkedList动态结点</b></font></div><div>import java.util.*;</div><div>import java.util.regex.*;</div><div>import java.text.*;</div><div>import java.math.*;</div><div><br></div><div><br></div><div>public class NonXorLife</div><div>{</div><div><span style="white-space:pre;"  > </span>public class node{</div><div><span style="white-space:pre;"  >  </span>int x,y,s;</div><div><span style="white-space:pre;"  >  </span>node(int x,int y,int s){</div><div><span style="white-space:pre;"  >   </span>this.x=x;</div><div><span style="white-space:pre;"  >   </span>this.y=y;</div><div><span style="white-space:pre;"  >   </span>this.s=s;</div><div><span style="white-space:pre;"  >  </span>}</div><div><span style="white-space:pre;"  >  </span>node(node n){</div><div><span style="white-space:pre;"  >   </span>x=n.x;</div><div><span style="white-space:pre;"  >   </span>y=n.y;</div><div><span style="white-space:pre;"  >   </span>s=n.s;</div><div><span style="white-space:pre;"  >  </span>}</div><div><span style="white-space:pre;"  > </span>}</div><div><span style="white-space:pre;"  > </span>public int countAliveCells(String[] field, int K)</div><div><span style="white-space:pre;"  > </span>{</div><div><span style="white-space:pre;"  >  </span>Queue&lt;node&gt; que=new java.util.LinkedList&lt;node&gt;(); //使用动态的链表作为结点</div><div><span style="white-space:pre;"  >  </span>int[] dx={1,-1,0,0};</div><div><span style="white-space:pre;"  >  </span>int[] dy={0,0,1,-1};</div><div><span style="white-space:pre;"  >  </span>int res=0;</div><div><span style="white-space:pre;"  >  </span>int n=field.length,m=field[0].length();</div><div><span style="white-space:pre;"  >  </span>boolean[][] chk=new boolean[4000][4000];</div><div><span style="white-space:pre;"  >  </span>for(int i=0; i&lt;n; i++){</div><div><span style="white-space:pre;"  >   </span>for(int j=0; j&lt;m; j++){</div><div><span style="white-space:pre;"  >    </span>if(field[i].charAt(j)=='o' &amp;&amp; !chk[i+2000][j+2000]){</div><div><span style="white-space:pre;"  >     </span>chk[i+2000][j+2000]=true;</div><div><span style="white-space:pre;"  >     </span>node tmp=new node(i+2000,j+2000,0);</div><div><span style="white-space:pre;"  >     </span>que.offer(tmp);</div><div><span style="white-space:pre;"  >     </span>res++;</div><div><span style="white-space:pre;"  >    </span>}</div><div><span style="white-space:pre;"  >   </span>}</div><div><span style="white-space:pre;"  >  </span>}</div><div><span style="white-space:pre;"  >  </span>while(!que.isEmpty()){</div><div><span style="white-space:pre;"  >   </span>node tmp=new node(que.poll());</div><div><span style="white-space:pre;"  >   </span>if(tmp.s&gt;=K) break;</div><div><span style="white-space:pre;"  >   </span>int x=tmp.x;</div><div><span style="white-space:pre;"  >   </span>int y=tmp.y;</div><div><span style="white-space:pre;"  >   </span>//System.out.println(x+" "+y+" "+tmp.s);</div><div><span style="white-space:pre;"  >   </span>for(int i=0; i&lt;4; i++){</div><div><span style="white-space:pre;"  >    </span>int tx=x+dx[i];</div><div><span style="white-space:pre;"  >    </span>int ty=y+dy[i];</div><div><span style="white-space:pre;"  >    </span>if(!chk[tx][ty]){</div><div><span style="white-space:pre;"  >     </span>chk[tx][ty]=true;</div><div><span style="white-space:pre;"  >     </span>node ad=new node(tx,ty,tmp.s+1);</div><div><span style="white-space:pre;"  >     </span>que.offer(ad);</div><div><span style="white-space:pre;"  >     </span>res++;</div><div><span style="white-space:pre;"  >    </span>}<span style="white-space:pre;"  >    </span></div><div><span style="white-space:pre;"  >   </span>}</div><div><span style="white-space:pre;"  >  </span>}</div><div><span style="white-space:pre;"  >  </span>return res;</div><div><span style="white-space:pre;"  > </span>}</div><div>}</div><div>//Powered by KawigiEdit 2.1.4 (beta) modified by pivanof!</div><wbr></div>]]></description>
	    <author><![CDATA[long1]]></author>
	    <comments>http://blog.163.com/lfw2565295@126/blog/static/122005162012415102114769</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/lfw2565295@126/blog/static/122005162012415102114769</guid>
    <pubDate>Tue, 15 May 2012 10:21:14 +0800</pubDate>
    <dcterms:modified>2012-05-15T10:21:48+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[(zz) Java: Queue]]></title>	
    <link>http://blog.163.com/lfw2565295@126/blog/static/1220051620124159479591</link>
    <description><![CDATA[<div><span style="color: rgb(154, 154, 154); font-family: arial; font-size: 12px; line-height: 18px;"  >学习Java: Queue队列<table style="border-collapse: collapse; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; table-layout: fixed;"  ><tbody><tr><td style="word-wrap: break-word; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><div style="word-wrap: break-word;"  >Java提供了Quere，相当好用，在1.5版本中又有增强。</div></td></tr></table></span><span style="font-family: simsun;"  ><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 22px;"  ><strong style="font-weight: bold; line-height: 22px;"  >add</strong>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;增加一个元索&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;如果队列已满，则抛出一个IIIegaISlabEepeplian异常<br style="line-height: 22px;"  ><strong style="font-weight: bold; line-height: 22px;"  >remove</strong>&nbsp;<wbr>&nbsp;<wbr>&nbsp;移除并返回队列头部的元素&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;如果队列为空，则抛出一个NoSuchElementException异常<br style="line-height: 22px;"  ><strong style="font-weight: bold; line-height: 22px;"  >element&nbsp;<wbr>&nbsp;<wbr></strong>返回队列头部的元素&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;如果队列为空，则抛出一个NoSuchElementException异常<br style="line-height: 22px;"  ><strong style="font-weight: bold; line-height: 22px;"  >offer</strong>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;添加一个元素并返回true&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>如果队列已满，则返回false<br style="line-height: 22px;"  ><strong style="font-weight: bold; line-height: 22px;"  >poll</strong>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;移除并返问队列头部的元素&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>如果队列为空，则返回null<br style="line-height: 22px;"  ><strong style="font-weight: bold; line-height: 22px;"  >peek</strong>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;返回队列头部的元素&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;如果队列为空，则返回null<br style="line-height: 22px;"  ><strong style="font-weight: bold; line-height: 22px;"  >put</strong>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;添加一个元素&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;如果队列满，则阻塞<br style="line-height: 22px;"  ><strong style="font-weight: bold; line-height: 22px;"  >take</strong>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;移除并返回队列头部的元素&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;如果队列为空，则阻塞</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 22px;"  >&nbsp;<wbr></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 22px;"  >remove、element、offer&nbsp;<wbr>、poll、peek&nbsp;<wbr>其实是属于Queue接口。&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 22px;"  ><br></p></span><span style="color: rgb(154, 154, 154); font-family: arial; font-size: 12px; line-height: 18px;"  ><table style="border-collapse: collapse; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; table-layout: fixed;"  ><tbody><tr><td style="word-wrap: break-word; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><div style="word-wrap: break-word;"  ><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(109, 109, 109); line-height: 26px;"  ><font size="5"  ><strong>Queue</strong></font>： 基本上，一个队列就是一个先入先出（FIFO）的数据结构<br><br><strong>offer，add区别：</strong><br>一些队列有大小限制，因此如果想在一个满的队列中加入一个新项，多出的项就会被拒绝。<br>这时新的 offer 方法就可以起作用了。它不是对调用 add() 方法抛出一个 unchecked 异常，而只是得到由 offer() 返回的 false。&nbsp;<br><br><strong>poll，remove区别：</strong><br>remove() 和 poll() 方法都是从队列中删除第一个元素（head）。remove() 的行为与 Collection 接口的版本相似，<br>但是新的 poll() 方法在用空集合调用时不是抛出异常，只是返回 null。因此新的方法更适合容易出现异常条件的情况。<br><br><strong>peek，element区别：</strong><br>element() 和 peek() 用于在队列的头部查询元素。与 remove() 方法类似，在队列为空时， element() 抛出一个异常，而 peek() 返回 null。<br><br>-----------------------------------------------------------------------------------------<br><strong>Tiger中有2组Queue的实现：</strong>实现了新的BlockingQueue接口的<br>和没有实现的<br><br>-------------------------------------------------------------<br><strong>没有实现的阻塞接口的：</strong>LinkedList： 实现了java.util.Queue接口<br>java.util.AbstractQueue<br>内置的不阻塞队列： PriorityQueue 和 ConcurrentLinkedQueue<br><br>PriorityQueue 和 ConcurrentLinkedQueue 类在 Collection Framework 中加入两个具体集合实现。&nbsp;<br><br>PriorityQueue 类实质上维护了一个有序列表。加入到 Queue 中的元素根据它们的天然排序（通过其 java.util.Comparable 实现）或者根据传递给构造函数的 java.util.Comparator 实现来定位。<br><br>ConcurrentLinkedQueue 是基于链接节点的、线程安全的队列。并发访问不需要同步。因为它在队列的尾部添加元素并从头部删除它们，所以只要不需要知道队列的大小，ConcurrentLinkedQueue 对公共集合的共享访问就可以工作得很好。收集关于队列大小的信息会很慢，需要遍历队列。<br><br>------------------------------------------------------------------<br><strong>实现阻塞接口的：</strong><br><br>新的 java.util.concurrent 包在 Collection Framework 中可用的具体集合类中加入了 BlockingQueue 接口和五个阻塞队列类。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(109, 109, 109); line-height: 26px;"  >它实质上就是一种带有一点扭曲的 FIFO 数据结构。不是立即从队列中添加或者删除元素，线程执行操作阻塞，直到有空间或者元素可用。<br><br>五个队列所提供的各有不同：<br><br>*&nbsp;<strong>ArrayBlockingQueue</strong>&nbsp;：一个由数组支持的有界队列。<br>*&nbsp;<strong>LinkedBlockingQueue</strong>&nbsp;：一个由链接节点支持的可选有界队列。<br>*&nbsp;<strong>PriorityBlockingQueue</strong>&nbsp;：一个由优先级堆支持的无界优先级队列。<br>*&nbsp;<strong>DelayQueue</strong>&nbsp;：一个由优先级堆支持的、基于时间的调度队列。<br>*&nbsp;<strong>SynchronousQueue</strong>&nbsp;：一个利用 BlockingQueue 接口的简单聚集（rendezvous）机制。<br><br><br>前两个类&nbsp;<strong>ArrayBlockingQueue</strong>&nbsp;和&nbsp;<strong>LinkedBlockingQueue</strong>&nbsp;几乎相同，只是在后备存储器方面有所不同， LinkedBlockingQueue 并不总是有容量界限。无大小界限的 LinkedBlockingQueue 类在添加元素时永远不会有阻塞队列的等待（至少在其中有Integer.MAX_VALUE 元素之前不会）。<br><br><strong>PriorityBlockingQueue</strong>&nbsp;是具有无界限容量的队列，它利用所包含元素的 Comparable 排序顺序来以逻辑顺序维护元素。可以将它看作 TreeSet 的可能替代物。不过对 PriorityBlockingQueue 有一个技巧。从 iterator() 返回的 Iterator 实例不需要以优先级顺序返回元素。如果必须以优先级顺序遍历所有元素，那么让它们都通过 toArray() 方法并自己对它们排序，像 Arrays.sort(pq.toArray())。<br><br>新的&nbsp;<strong>DelayQueue</strong>&nbsp;实现可能是其中最有意思（也是最复杂）的一个。加入到队列中的元素必须实现新的 Delayed 接口（只有一个方法 —— long getDelay(java.util.concurrent.TimeUnit unit) ）。因为队列的大小没有界限，使得添加可以立即返回，但是在延迟时间过去之前不能从队列中取出元素。如果多个元素完成了延迟，那么最早失效/失效时间最长的元素将第一个取出。实际上没有听上去这样复杂。<br><br><strong>SynchronousQueue</strong>&nbsp;类是最简单的。它没有内部容量。它就像线程之间的手递手机制。在队列中加入一个元素的生产者会等待另一个线程的消费者。当这个消费者出现时，这个元素就直接在消费者和生产者之间传递，永远不会加入到阻塞队列中。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(109, 109, 109); line-height: 26px;"  >----------------------------------------------<br>实验结果：<br><br>文档说BlockingQueue的队列： 不是立即从队列中添加或者删除元素，线程执行操作阻塞，直到有空间或者元素可用。<br><br>实验了一下，使用put、take是这样子的,线程在等待<br>而使用offer是立刻返回false的</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(109, 109, 109); line-height: 26px;"  ><br></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 26px;"  ><b><font color="#0000ff"  >srm541 div2 1000题用queue做宽搜</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  >//1000</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  >//规模在4000*4000以内，直接宽搜，已经存在的点直接放入队列，然后四个方向扩展</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  >//用数组盘重，用到了java的Queue的offer和poll, 记忆LinkedList动态结点</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  >import java.util.*;</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  >import java.util.regex.*;</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  >import java.text.*;</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  >import java.math.*;</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><br></font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><br></font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  >public class NonXorLife</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  >{</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  > </span>public class node{</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  >  </span>int x,y,s;</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  >  </span>node(int x,int y,int s){</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  >   </span>this.x=x;</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  >   </span>this.y=y;</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  >   </span>this.s=s;</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  >  </span>}</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  >  </span>node(node n){</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  >   </span>x=n.x;</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  >   </span>y=n.y;</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  >   </span>s=n.s;</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  >  </span>}</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  > </span>}</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  > </span>public int countAliveCells(String[] field, int K)</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  > </span>{</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  >  </span>Queue&lt;node&gt; que=new java.util.LinkedList&lt;node&gt;(); //使用动态的链表作为结点</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  >  </span>int[] dx={1,-1,0,0};</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  >  </span>int[] dy={0,0,1,-1};</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  >  </span>int res=0;</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  >  </span>int n=field.length,m=field[0].length();</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  >  </span>boolean[][] chk=new boolean[4000][4000];</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  >  </span>for(int i=0; i&lt;n; i++){</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  >   </span>for(int j=0; j&lt;m; j++){</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  >    </span>if(field[i].charAt(j)=='o' &amp;&amp; !chk[i+2000][j+2000]){</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  >     </span>chk[i+2000][j+2000]=true;</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  >     </span>node tmp=new node(i+2000,j+2000,0);</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  >     </span>que.offer(tmp);</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  >     </span>res++;</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  >    </span>}</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  >   </span>}</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  >  </span>}</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  >  </span>while(!que.isEmpty()){</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  >   </span>node tmp=new node(que.poll());</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  >   </span>if(tmp.s&gt;=K) break;</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  >   </span>int x=tmp.x;</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  >   </span>int y=tmp.y;</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  >   </span>//System.out.println(x+" "+y+" "+tmp.s);</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  >   </span>for(int i=0; i&lt;4; i++){</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  >    </span>int tx=x+dx[i];</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  >    </span>int ty=y+dy[i];</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  >    </span>if(!chk[tx][ty]){</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  >     </span>chk[tx][ty]=true;</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  >     </span>node ad=new node(tx,ty,tmp.s+1);</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  >     </span>que.offer(ad);</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  >     </span>res++;</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  >    </span>}<span style="white-space:pre;"  >    </span></font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  >   </span>}</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  >  </span>}</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  >  </span>return res;</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  ><span style="white-space:pre;"  > </span>}</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  >}</font></b></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  >//Powered by KawigiEdit 2.1.4 (beta) modified by pivanof!</font></b></p></div></td></tr></table></span><wbr></div>]]></description>
	    <author><![CDATA[long1]]></author>
	    <comments>http://blog.163.com/lfw2565295@126/blog/static/1220051620124159479591</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/lfw2565295@126/blog/static/1220051620124159479591</guid>
    <pubDate>Tue, 15 May 2012 10:18:35 +0800</pubDate>
    <dcterms:modified>2012-05-15T10:18:35+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[JAVA的Random类(转)]]></title>	
    <link>http://blog.163.com/lfw2565295@126/blog/static/122005162012499160892</link>
    <description><![CDATA[<div><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >Random类<span>&nbsp;(java.util)<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >Random类中实现的随机算法是伪随机，也就是有规则的随机。在进行随机时，随机算法的起源数字称为种子数<span>(seed)，在种子数的基础上进行一定的变换，从而产生需要的随机数字。</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >相同种子数的<span>Random对象，相同次数生成的随机数字是完全相同的。也就是说，两个种子数相同的Random对象，第一次生成的随机数字完全相同，第二次生成的随机数字也完全相同。这点在生成多个随机数字时需要特别注意。</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >下面介绍一下<span>Random类的使用，以及如何生成指定区间的随机数组以及实现程序中要求的几率。</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >1、<span>Random对象的生成</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Random</span>类包含两个构造方法，下面依次进行介绍：</p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a</span>、<span>public Random()</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >该构造方法使用一个和当前系统时间对应的相对时间有关的数字作为种子数，然后使用这个种子数构造<span>Random对象。</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; b</span>、<span>public Random(long seed)</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >该构造方法可以通过制定一个种子数进行创建。</p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >示例代码：</p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >Random r = new Random();</p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >Random r1 = new Random(10);</p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >再次强调：种子数只是随机算法的起源数字，和生成的随机数字的区间无关。</p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >2、<span>Random类中的常用方法</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >Random类中的方法比较简单，每个方法的功能也很容易理解。需要说明的是，<span>Random类中各方法生成的随机数字都是均匀分布的，也就是说区间内部的数字生成的几率是均等的。下面对这些方法做一下基本的介绍：</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >a、<span>public boolean nextBoolean()</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >该方法的作用是生成一个随机的<span>boolean值，生成true和false的值几率相等，也就是都是50%的几率。</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >b、<span>public double nextDouble()</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >该方法的作用是生成一个随机的<span>double值，数值介于[0,1.0)之间。</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ></p><font face="Verdana"  ><span style="line-height: 21px;"  >c、</span></font><span style="font-family: Verdana; line-height: 21px;"  >public int nextInt()</span><p style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >该方法的作用是生成一个随机的<span>int值，该值介于int的区间，也就是-231到231-1之间。</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >如果需要生成指定区间的<span>int值，则需要进行一定的数学变换，具体可以参看下面的使用示例中的代码。</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >d、<span>public int nextInt(int n)</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >该方法的作用是生成一个随机的<span>int值，该值介于[0,n)的区间，也就是0到n之间的随机int值，包含0而不包含n。</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >如果想生成指定区间的<span>int值，也需要进行一定的数学变换，具体可以参看下面的使用示例中的代码。</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >e、<span>public void setSeed(long seed)</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >该方法的作用是重新设置<span>Random对象中的种子数。设置完种子数以后的Random对象和相同种子数使用new关键字创建出的Random对象相同。</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >3、<span>Random类使用示例</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >使用<span>Random类，一般是生成指定区间的随机数字，下面就一一介绍如何生成对应区间的随机数字。以下生成随机数的代码均使用以下Random对象r进行生成：</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >Random r = new Random();</p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >a、生成<span>[0,1.0)区间的小数</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; double d1 = r.nextDouble();</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >直接使用<span>nextDouble方法获得。</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >b、生成<span>[0,5.0)区间的小数</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >double d2 = r.nextDouble() * 5;</p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >因为<span>nextDouble方法生成的数字区间是[0,1.0)，将该区间扩大5倍即是要求的区间。</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >同理，生成<span>[0,d)区间的随机小数，d为任意正的小数，则只需要将nextDouble方法的返回值乘以d即可。</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >c、生成<span>[1,2.5)区间的小数</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; double d3 = r.nextDouble() * 1.5 + 1;</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >生成<span>[1,2.5)区间的随机小数，则只需要首先生成[0,1.5)区间的随机数字，然后将生成的随机数区间加1即可。</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >同理，生成任意非从<span>0开始的小数区间[d1,d2)范围的随机数字(其中d1不等于0)，则只需要首先生成[0,d2-d1)区间的随机数字，然后将生成的随机数字区间加上d1即可。</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >d、生成任意整数</p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >int n1 = r.nextInt();</p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >直接使用<span>nextInt方法即可。</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >e、生成<span>[0,10)区间的整数</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >int n2 = r.nextInt(10);</p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >n2 = Math.abs(r.nextInt() % 10);</p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >以上两行代码均可生成<span>[0,10)区间的整数。</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >第一种实现使用<span>Random类中的nextInt(int n)方法直接实现。</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >第二种实现中，首先调用<span>nextInt()方法生成一个任意的int数字，该数字和10取余以后生成的数字区间为(-10,10)，然后再对该区间求绝对值，则得到的区间就是[0,10)了。</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >同理，生成任意<span>[0,n)区间的随机整数，都可以使用如下代码：</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >int n2 = r.nextInt(n);</p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >n2 = Math.abs(r.nextInt() % n);</p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >f、生成<span>[0,10]区间的整数</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >int n3 = r.nextInt(11);</p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >n3 = Math.abs(r.nextInt() % 11);</p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >相对于整数区间，<span>[0,10]区间和[0,11)区间等价，所以即生成[0,11)区间的整数。</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >g、生成<span>[-3,15)区间的整数</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >int n4 = r.nextInt(18) - 3;</p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >n4 = Math.abs(r.nextInt() % 18) - 3;</p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >生成非从<span>0开始区间的随机整数，可以参看上面非从0开始的小数区间实现原理的说明。</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >h、几率实现</p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >按照一定的几率实现程序逻辑也是随机处理可以解决的一个问题。下面以一个简单的示例演示如何使用随机数字实现几率的逻辑。</p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >在前面的方法介绍中，<span>nextInt(int n)方法中生成的数字是均匀的，也就是说该区间内部的每个数字生成的几率是相同的。那么如果生成一个[0,100)区间的随机整数，则每个数字生成的几率应该是相同的，而且由于该区间中总计有100个整数，所以每个数字的几率都是1%。按照这个理论，可以实现程序中的几率问题。</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >示例：随机生成一个整数，该整数以<span>55%的几率生成1，以40%的几率生成2，以5%的几率生成3。实现的代码如下：</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >int n5 = r.nextInt(100);</p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >int m; //结果数字</p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >if(n5 &lt; 55){ //55个数字的区间，<span>55%的几率</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >m = 1;</p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >}else if(n5 &lt; 95){//[55,95)，<span>40个数字的区间，40%的几率</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >m = 2;</p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >}else{</p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >m = 3;</p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >}</p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >因为每个数字的几率都是<span>1%，则任意55个数字的区间的几率就是55%，为了代码方便书写，这里使用[0,55)区间的所有整数，后续的原理一样。</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >当然，这里的代码可以简化，因为几率都是<span>5%的倍数，所以只要以5%为基础来控制几率即可，下面是简化的代码实现：</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int n6 = r.nextInt(20);</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><span>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int m1;</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(n6 &lt; 11){</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m1 = 1;</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }else if(n6 &lt; 19){</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m1= 2;</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }else{</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m1 = 3;</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>在程序内部，几率的逻辑就可以按照上面的说明进行实现。</p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >4、其它问题</p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >a、相同种子数<span>Random对象问题</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >前面介绍过，相同种子数的<span>Random对象，相同次数生成的随机数字是完全相同的，下面是测试的代码：</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Random r1 = new Random(10);</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Random r2 = new Random(10);</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for(int i = 0;i &lt; 2;i++){</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;System.out.println(r1.nextInt());</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(r2.nextInt());</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >在该代码中，对象<span>r1和r2使用的种子数都是10，则这两个对象相同次数生成的随机数是完全相同的。</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >如果想避免出现随机数字相同的情况，则需要注意，无论项目中需要生成多少个随机数字，都只使用一个<span>Random对象即可。</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >b、关于<span>Math类中的random方法</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >其实在<span>Math类中也有一个random方法，该random方法的工作是生成一个[0,1.0)区间的随机小数。</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >通过阅读<span>Math类的源代码可以发现，Math类中的random方法就是直接调用Random类中的nextDouble方法实现的。</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  >只是<span>random方法的调用比较简单，所以很多程序员都习惯使用Math类的random方法来生成随机数字。</span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><span><br></span></p><p align="left"  style="font-family: Verdana; line-height: 21px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><font size="4"  color="#0000ff"  ><b>我使用的例子：</b></font></p><p align="left"  style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ></p><p align="left"  style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><font face="Verdana"  >import java.util.*;</font></p><p align="left"  style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><font face="Verdana"  >import java.io.*;</font></p><p align="left"  style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><font face="Verdana"  ><br></font></p><p align="left"  style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><font face="Verdana"  >public class Main {</font></p><p align="left"  style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><font face="Verdana"  ><span style="white-space:pre;"  > </span>private static int N=6;</font></p><p align="left"  style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><font face="Verdana"  ><span style="white-space:pre;"  > </span>private static String[] attr={"occupation","industry","workclass","education","majorocc","majorind"};</font></p><p align="left"  style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><font face="Verdana"  ><span style="white-space:pre;"  > </span>private static int[] num={47,52,10,17,15,24};</font></p><p align="left"  style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><font face="Verdana"  ><span style="white-space:pre;"  > </span>public static void main(String[] args){</font></p><p align="left"  style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><font face="Verdana"  ><span style="white-space:pre;"  >  </span>try{</font></p><p align="left"  style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><font face="Verdana"  ><span style="white-space:pre;"  >   </span>//FileReader inputfile=new FileReader("a.in");</font></p><p align="left"  style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><font face="Verdana"  ><span style="white-space:pre;"  >   </span>//BufferedReader inputstream=new BufferedReader(inputfile);</font></p><p align="left"  style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><font face="Verdana"  ><span style="white-space:pre;"  >   </span>FileWriter outputfile=new FileWriter("randonlydata.in");</font></p><p align="left"  style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><font face="Verdana"  ><span style="white-space:pre;"  >   </span>BufferedWriter out=new BufferedWriter(outputfile);</font></p><p align="left"  style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><span style="white-space:pre;"  ><font face="Verdana"  >   </font></span></p><p align="left"  style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><font face="Verdana"  ><span style="white-space:pre;"  >   </span>for(int i=0; i&lt;N; i++){</font></p><p align="left"  style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><font face="Verdana"  ><span style="white-space:pre;"  >    </span>if(i&gt;0) out.write(" # ");</font></p><p align="left"  style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><font face="Verdana"  ><span style="white-space:pre;"  >    </span>out.write(attr[i]);</font></p><p align="left"  style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><font face="Verdana"  ><span style="white-space:pre;"  >   </span>}</font></p><p align="left"  style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><font face="Verdana"  size="4"  color="#0000ff"  ><b><span style="white-space:pre;"  >   </span>out.write("\n");</b></font></p><p align="left"  style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><font face="Verdana"  size="4"  color="#0000ff"  ><b><span style="white-space:pre;"  >   </span>Random r = new Random(); //if double. simply use Math.random()</b></font></p><p align="left"  style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><font face="Verdana"  ><span style="white-space:pre;"  >   </span>for(int i=0; i&lt;10000; i++){</font></p><p align="left"  style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><font face="Verdana"  ><span style="white-space:pre;"  >    </span>int[] val=new int[N];</font></p><p align="left"  style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><font face="Verdana"  ><span style="white-space:pre;"  >    </span>out.write("linenum"+i+": ");</font></p><p align="left"  style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><font face="Verdana"  ><span style="white-space:pre;"  >    </span>for(int j=0; j&lt;N; j++){</font></p><p align="left"  style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><font face="Verdana"  ><span style="white-space:pre;"  >     </span>if(j&gt;0) out.write(" # ");</font></p><p align="left"  style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><font face="Verdana"  size="4"  color="#0000ff"  ><b><span style="white-space:pre;"  >     </span>val[j]=Math.abs( r.nextInt() )%num[j]; //if I use r.nextInt(num[j]), everytime values are same</b></font></p><p align="left"  style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><font face="Verdana"  ><span style="white-space:pre;"  >     </span>out.write(""+val[j]);</font></p><p align="left"  style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><font face="Verdana"  ><span style="white-space:pre;"  >    </span>}</font></p><p align="left"  style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><font face="Verdana"  ><span style="white-space:pre;"  >    </span>out.write("\n");</font></p><p align="left"  style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><font face="Verdana"  ><span style="white-space:pre;"  >   </span>}</font></p><p align="left"  style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><font face="Verdana"  color="#0000ff"  size="3"  ><b>&nbsp; &nbsp;out.close(); //记得加 close</b></font></p><p align="left"  style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><font face="Verdana"  ><span style="white-space:pre;"  >  </span>}catch(IOException e){</font></p><p align="left"  style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><font face="Verdana"  ><span style="white-space:pre;"  >   </span>System.out.println("The load may be error!");</font></p><p align="left"  style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><font face="Verdana"  ><span style="white-space:pre;"  >   </span>e.printStackTrace();</font></p><p align="left"  style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><font face="Verdana"  ><span style="white-space:pre;"  >  </span>}</font></p><p align="left"  style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><font face="Verdana"  ><span style="white-space:pre;"  > </span>}</font></p><p align="left"  style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px;"  ><font face="Verdana"  >}</font></p><div style="font-family: Verdana; line-height: 21px;"  ><br></div><wbr></div>]]></description>
	    <author><![CDATA[long1]]></author>
	    <comments>http://blog.163.com/lfw2565295@126/blog/static/122005162012499160892</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/lfw2565295@126/blog/static/122005162012499160892</guid>
    <pubDate>Wed, 9 May 2012 21:16:00 +0800</pubDate>
    <dcterms:modified>2012-05-11T12:38:22+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[热情高涨的五月]]></title>	
    <link>http://blog.163.com/lfw2565295@126/blog/static/1220051620124912118691</link>
    <description><![CDATA[<div><div>4月过的真快，一下到了5月，主要4月事情也真多</div><div>回了一趟家，去了N次杭州，找实习，准备ZJNU邀请赛，一晃就到了5月</div><div>虽然组织过校赛，但组织邀请赛这样大型的赛事，比预想的麻烦多了，我是主要负责系统组，我们学校29幢机房是无盘工作站，没有硬盘，启动系统和存储文件都靠几台大服务器，方便管理，但给我们的工作，一开始造成了很多麻烦。</div><div>首先我们组想用11.10版本的ubuntu，结果公司的人说他们暂时还没刻最新的内核，所以让我们找老版本，于是我们尝试10.04，结果发现还是不行，能用的版本是9.04，9.10。无奈我们装了9.10后，发现ubuntu软件中心不支持了，很多软件需要网上手动找资源，下载安装，恶心的是软件还有依赖关系，不能用apt-get install方法真恶心，大部分搞定后，最后g++一时弄不好，旧版本也不好拿出手。于是找公司看他们能不能做个11.10内核，同时学校里做好买150个硬盘的准备。不过还好，公司及时弄好了内核，我们预装的系统和环境全部可以上传到服务器，然后发布到各个无盘电脑。</div><div>接下来是搞懂pc^2的使用，摸索了一段时间，测试了好几场练习赛，还有配置气球打印机，打印机，排名机，工程量很大，并且要多次测试，尤其打印服务总是莫名的出问题，热身赛前1小时还出问题了，幸好比赛中没出问题。</div><div>还有就是系统安全方面，周维民的儿子周智凯是个神牛，帮我们弄了服务器同传，还有发现我们没有禁掉两台机器间的通讯，较我们方法，正是赛时选手机只能访问固定几个ip了</div><div>整个比赛下来，还算顺利，A题数据发生了小错误，这个北大郭老师亲自出的，在比赛中途rejudge了，不过大部分队伍可能影响不大，这个错误也是平时我们也容易烦的，就是写了12个case，实际只有11个case，所以容易最后一个case莫名的错了，写的常规点的代码也能1A，因为这题最简单，大部分队伍都过了，所以影响还好。</div><div>赛后以为终于解放了，发现打印奖状是个大的体力活，留下10名左右的集训队员一直工作到晚上9点半才和韩老师一起吃晚饭，当时大家都累死，饿死了。</div><div>不过总算邀请赛顺利结束了。事后有些新队员不懂事，发布一些选手的代码到网上，被我们批评了，总感觉现在的新队员责任心和原则性牵强，整个比赛下来，很多老队员做了很多事，忙到最后一刻，新队员总是需要他们做点体力活时都找不到人影，同时，没有一份跟着学习的心，感觉没事就离开了，这样的态度还是很难学到很多的。</div><div>很多学校也有这样的感觉，新老交替时，下一代容易被强大的上一代带惯了，功利性强了，热情度低了，福利好了，义务活少了，所以怀念我当年06级时代的人，那个时候大部分人都还很难取得成绩，但热情度比现在高多了，把机房当作自己寝室一样，有时还在机房通宵过。所以希望新一代人不管成绩怎么样，既然加入了集训队，付出的多一点，期待的少一点，享受过程多一点，荣誉看得轻一点，当一份爱情来对待！</div><div><div><img title="热情高涨的五月 - long1 - long1 vs longpo"  alt="热情高涨的五月 - long1 - long1 vs longpo"  style="margin:0 10px 0 0;"  src="http://img6.ph.126.net/4rbMLy8RY40MSfaNGbQp5w==/3088624919463519766.jpg"  ></div>&nbsp;<div><img title="热情高涨的五月 - long1 - long1 vs longpo"  alt="热情高涨的五月 - long1 - long1 vs longpo"  style="margin:0 10px 0 0;"  src="http://img6.ph.126.net/94B9hK4Ywef7_0BpmFtBUQ==/2564237037851565916.jpg"  ></div>&nbsp;<div><img title="热情高涨的五月 - long1 - long1 vs longpo"  alt="热情高涨的五月 - long1 - long1 vs longpo"  style="margin:0 10px 0 0;"  src="http://img8.ph.126.net/XjMm2Us5UxA86NghacT4aA==/2739314473365608488.jpg"  ></div>&nbsp;<div><img title="热情高涨的五月 - long1 - long1 vs longpo"  alt="热情高涨的五月 - long1 - long1 vs longpo"  style="margin:0 10px 0 0;"  src="http://img5.ph.126.net/OUkdyb9FKs8Wk8zeUUhumw==/1098033884165751795.jpg"  ></div>&nbsp;</div><wbr></div>]]></description>
	    <author><![CDATA[long1]]></author>
	    <comments>http://blog.163.com/lfw2565295@126/blog/static/1220051620124912118691</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/lfw2565295@126/blog/static/1220051620124912118691</guid>
    <pubDate>Wed, 9 May 2012 13:21:18 +0800</pubDate>
    <dcterms:modified>2012-05-09T13:21:18+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[SRM542 DIV2 250 500 950的题 模拟 矩形想法 组合概率]]></title>	
    <link>http://blog.163.com/lfw2565295@126/blog/static/1220051620124904453272</link>
    <description><![CDATA[<div><div><font color="#0000ff"  size="4"  ><b>这次TC没注册上，但还是看了下题，做了下，感觉有难度，DIV1 零分都排名280多，能涨分，所以可见难度有点，做了下DIV2的题，挺好的题，想法考的比较多</b></font></div><div><font color="#0000ff"  size="4"  ><b><br></b></font></div><div><font color="#0000ff"  size="4"  ><b>//250&nbsp;</b></font></div><div><font color="#0000ff"  size="4"  ><b>//模拟一下就可以了</b></font></div><div>import java.util.*;</div><div>import java.util.regex.*;</div><div>import java.text.*;</div><div>import java.math.*;</div><div><br></div><div><br></div><div>public class WorkingRabbits</div><div>{</div><div><span style="white-space:pre;"  > </span>public double getEfficiency(String[] profit)</div><div><span style="white-space:pre;"  > </span>{</div><div><span style="white-space:pre;"  >  </span>int n=profit.length;</div><div><span style="white-space:pre;"  >  </span>double sum=0;</div><div><span style="white-space:pre;"  >  </span>for(int i=0; i&lt;n; i++){</div><div><span style="white-space:pre;"  >   </span>for(int j=i+1; j&lt;n; j++){</div><div><span style="white-space:pre;"  >    </span>int tmp=(int)profit[i].charAt(j)-'0';</div><div><span style="white-space:pre;"  >    </span>sum+=(double)tmp;</div><div><span style="white-space:pre;"  >   </span>}</div><div><span style="white-space:pre;"  >  </span>}</div><div><span style="white-space:pre;"  >  </span>double total=(double)(n*(n-1))/2;</div><div><span style="white-space:pre;"  >  </span>return sum/total;</div><div><span style="white-space:pre;"  > </span>}</div><div>}</div><div>//Powered by KawigiEdit 2.1.4 (beta) modified by pivanof!</div><div><br></div><div><font size="4"  color="#0000ff"  ><b>//500</b></font></div><div><font size="4"  color="#0000ff"  ><b>//关键在于找技巧，固定矩形，A,B,C绕一圈，就相当于矩形周长</b></font></div><div><font size="4"  color="#0000ff"  ><b>//所以枚举小矩形长宽，计算数量</b></font></div><div>import java.util.*;</div><div>import java.util.regex.*;</div><div>import java.text.*;</div><div>import java.math.*;</div><div><br></div><div><br></div><div>public class PatrolRoute</div><div>{</div><div><span style="white-space:pre;"  > </span>public int countRoutes(int X, int Y, int minT, int maxT)</div><div><span style="white-space:pre;"  > </span>{</div><div><span style="white-space:pre;"  >  </span>long res=0;</div><div><span style="white-space:pre;"  >  </span>int mod=1000000007;</div><div><span style="white-space:pre;"  >  </span>for(int i=3; i&lt;=X; i++){</div><div><span style="white-space:pre;"  >   </span>for(int j=3; j&lt;=Y; j++){</div><div><span style="white-space:pre;"  >    </span>int t=(i+j-2)*2;&nbsp;</div><div><span style="white-space:pre;"  >    </span>//注意周长计算时，i个点，(i-1)边长</div><div><span style="white-space:pre;"  >    </span>if(t&lt;minT || t&gt;maxT) continue;</div><div><span style="white-space:pre;"  >    </span>long tmp=(long)(X-i+1)*(Y-j+1)*(i-2)*(j-2)*6;</div><div><span style="white-space:pre;"  >    </span>//(X-i+1)*(Y-j+1) 表示x*y大矩形里有多少i*j小矩形</div><div><span style="white-space:pre;"  >    </span>//(i-2)*(j-2)*4表示，固定一个顶点，剩下两个点必须放在边长上，且不重叠的情况，4个定点所以乘以4</div><div><span style="white-space:pre;"  >    </span>//(i-2)*(j-2)*2表示，固定对角一对顶点，剩下一个点必须在内嵌的矩形里面，2种对角所以乘以2</div><div><span style="white-space:pre;"  >    </span>//这两种情况合并就是 (i-2)*(j-2)*6</div><div><span style="white-space:pre;"  >    </span>res+=tmp;</div><div><span style="white-space:pre;"  >    </span>res%=mod;</div><div><span style="white-space:pre;"  >   </span>}</div><div><span style="white-space:pre;"  >  </span>}</div><div><span style="white-space:pre;"  >  </span>return (int)res;</div><div><span style="white-space:pre;"  > </span>}</div><div>}</div><div>//Powered by KawigiEdit 2.1.4 (beta) modified by pivanof!</div><div><br></div><div><font size="4"  color="#0000ff"  ><b>//950</b></font></div><div><font size="4"  color="#0000ff"  ><b>//res[i]+=c[m][cnt1+cnt2]*cnt2*f[cnt1+cnt2-1] * f[m-cnt1-cnt2] / f[m];</b></font></div><div><font size="4"  color="#0000ff"  ><b>//代表，字母一样的m-cnt1-cnt2个字母，位置随意</b></font></div><div><font size="4"  color="#0000ff"  ><b>//不一样的字母cnt1+cnt2中，保证第一个位置是cnt2中选出来的，其余的位置随意</b></font></div><div><font size="4"  color="#0000ff"  ><b>//f[m]总的位置安排</b></font></div><div><font size="4"  color="#0000ff"  ><b>//任意两个words比较，看排名倒退一位的概率</b></font></div><div><br></div><div>import java.util.*;</div><div>import java.util.regex.*;</div><div>import java.text.*;</div><div>import java.math.*;</div><div><br></div><div><br></div><div>public class StrangeDictionary</div><div>{</div><div><span style="white-space:pre;"  > </span>public double[] getExpectedPositions(String[] words)</div><div><span style="white-space:pre;"  > </span>{</div><div><span style="white-space:pre;"  >  </span>double[][] c=new double[55][55];</div><div><span style="white-space:pre;"  >  </span>double[] f=new double[55];</div><div><span style="white-space:pre;"  >  </span>for(int i=0; i&lt;=50; i++){ //计算组合数</div><div><span style="white-space:pre;"  >   </span>for(int j=0; j&lt;=i; j++){</div><div><span style="white-space:pre;"  >    </span>if(i==j || j==0) c[i][j]=1;</div><div><span style="white-space:pre;"  >    </span>else{</div><div><span style="white-space:pre;"  >     </span>c[i][j]=c[i-1][j];</div><div><span style="white-space:pre;"  >     </span>if(j-1&gt;=0) c[i][j]+=c[i-1][j-1];</div><div><span style="white-space:pre;"  >    </span>}</div><div><span style="white-space:pre;"  >   </span>}</div><div><span style="white-space:pre;"  >  </span>}</div><div><span style="white-space:pre;"  >  </span>f[0]=1;</div><div><span style="white-space:pre;"  >  </span>for(int i=1; i&lt;=50; i++) f[i]=f[i-1]*i; //计算阶层</div><div><span style="white-space:pre;"  >  </span>int n=words.length;</div><div><span style="white-space:pre;"  >  </span>int m=words[0].length();</div><div><span style="white-space:pre;"  >  </span>double[] res=new double[n];</div><div><span style="white-space:pre;"  >  </span>for(int i=0; i&lt;n; i++){</div><div><span style="white-space:pre;"  >   </span>res[i]=0.0;</div><div><span style="white-space:pre;"  >   </span>for(int j=0; j&lt;n; j++){</div><div><span style="white-space:pre;"  >    </span>if(i==j) continue;</div><div><span style="white-space:pre;"  >    </span>int cnt1=0,cnt2=0;</div><div><span style="white-space:pre;"  >    </span>for(int k=0; k&lt;m; k++){</div><div><span style="white-space:pre;"  >     </span>if(words[i].charAt(k)&lt;words[j].charAt(k)) cnt1++;</div><div><span style="white-space:pre;"  >     </span>if(words[i].charAt(k)&gt;words[j].charAt(k)) cnt2++;</div><div><span style="white-space:pre;"  >    </span>}</div><div><span style="white-space:pre;"  >    </span>res[i]+=c[m][cnt1+cnt2]*cnt2*f[cnt1+cnt2-1] * f[m-cnt1-cnt2] / f[m];</div><div><span style="white-space:pre;"  >    </span>//代表，字母一样的m-cnt1-cnt2个字母，位置随意</div><div><span style="white-space:pre;"  >    </span>//不一样的字母cnt1+cnt2中，保证第一个位置是cnt2中选出来的，其余的位置随意</div><div><span style="white-space:pre;"  >    </span>//f[m]总的位置安排</div><div><span style="white-space:pre;"  >    </span>//任意两个words比较，看排名倒退一位的概率</div><div><span style="white-space:pre;"  >   </span>}</div><div><span style="white-space:pre;"  >  </span>}</div><div><span style="white-space:pre;"  >  </span>return res;</div><div><span style="white-space:pre;"  > </span>}</div><div>}</div><div>//Powered by KawigiEdit 2.1.4 (beta) modified by pivanof!</div><div><br></div><div><font size="4"  color="#0000ff"  ><b>题目：</b></font></div><div><font size="4"  color="#0000ff"  ><b>250：</b></font></div><div><table>       <tbody><tr>         <td colspan="2"  >           <h3>             Problem Statement           </h3>         </td>       </tr>       <tr>         <td>           &nbsp;&nbsp;&nbsp;&nbsp;         </td>         <td>           N rabbits (numbered 0 through N - 1) are going to work together at            the new TopCoder office in Rabbitland.<br><br>Each pair of rabbits            will make a certain profit when they work together. The <i>efficiency</i>            of the group of rabbits is defined as follows: Let P be the sum of            profits from all pairs of rabbits, and Q be the number of pairs of            rabbits. Then the efficiency is the real number P / Q.<br><br>You            are given a String[] <b>profit</b>, the j-th character of the i-th            element of which represents the profit from the fact that rabbits i            and j work together. The characters '0', '1', ..., '9' represent the            values 0, 1, ..., 9, respectively. Compute and return the efficiency            of this TopCoder office.         </td>       </tr>       <tr>         <td colspan="2"  >           <h3>             Definition           </h3>         </td>       </tr>       <tr>         <td>           &nbsp;&nbsp;&nbsp;&nbsp;         </td>         <td>           <table>             <tbody><tr>               <td>                 Class:               </td>               <td>                 WorkingRabbits               </td>             </tr>             <tr>               <td>                 Method:               </td>               <td>                 getEfficiency               </td>             </tr>             <tr>               <td>                 Parameters:               </td>               <td>                 String[]               </td>             </tr>             <tr>               <td>                 Returns:               </td>               <td>                 double               </td>             </tr>             <tr>               <td>                 Method signature:               </td>               <td>                 double getEfficiency(String[] profit)               </td>             </tr>             <tr>               <td colspan="2"  >                 (be sure your method is public)               </td>             </tr>           </table>         </td>       </tr>       <tr>         <td>           &nbsp;&nbsp;&nbsp;&nbsp;         </td>       </tr>       <tr>         <td>                    </td>       </tr>       <tr>         <td colspan="2"  >           <h3>             Notes           </h3>         </td>       </tr>       <tr>         <td valign="top"  align="center"  >           -         </td>         <td>           The returned value must have an absolute or relative error less than            1e-9.         </td>       </tr>       <tr>         <td colspan="2"  >           <h3>             Constraints           </h3>         </td>       </tr>       <tr>         <td valign="top"  align="center"  >           -         </td>         <td>           <b>profit</b> will contain between 2 and 50 elements, inclusive.         </td>       </tr>       <tr>         <td valign="top"  align="center"  >           -         </td>         <td>           Each element of <b>profit</b> will contain exactly N characters,            where N is the number of elements in <b>profit</b>.         </td>       </tr>       <tr>         <td valign="top"  align="center"  >           -         </td>         <td>           Each character in each element of <b>profit</b> will be a digit ('0'            - '9').         </td>       </tr>       <tr>         <td valign="top"  align="center"  >           -         </td>         <td>           For each index i and j, the i-th character of the j-th element of <b>profit</b>            will be equal to the j-th character of the i-th element of <b>profit</b>.         </td>       </tr>       <tr>         <td valign="top"  align="center"  >           -         </td>         <td>           For each index i, the i-th character of the i-th element of <b>profit</b>            will be '0'.         <br><br><font size="4"  color="#0000ff"  ><b>500：</b></font><br><table>       <tbody><tr>         <td colspan="2"  >           <h3>             Problem Statement           </h3>         </td>       </tr>       <tr>         <td>           &nbsp;&nbsp;&nbsp;&nbsp;         </td>         <td>           <p>             There are exactly <b>X</b>*<b>Y</b> places in the Planar Kingdom:              For each pair of integers (x, y) such that 0 &lt;= x &lt; <b>X</b>              and 0 &lt;= y &lt; <b>Y</b> there is a place with coordinates (x,              y). When a citizen of the kingdom wants to move from (x1, y1) to              (x2, y2), the required time is |x1 - x2| + |y1 - y2| (where |t|              denotes the absolute value of t).           </p>           <p>                        </p>           <p>             In order to improve stability in the kingdom, the police wants to              introduce a specific <i>patrol route</i>. The route will contain              exactly three places A, B, and C. A policeman will visit these              three places and verify that everything is as it should be. The              three places that determine a valid route must satisfy the              following criteria::           </p>           <ul>             <li>               x-coordinates of A, B and C are pairwise distinct.             </li>             <li>               y-coordinates of A, B and C are pairwise distinct.             </li>             <li>               Let T be the total time required to follow along the route:                first from A to B, then from B to C and finally from C back to                A. T must be between <b>minT</b> and <b>maxT</b>, inclusive.             </li>           </ul>           <p>                        </p>           You are given the ints <b>X</b>, <b>Y</b>, <b>minT</b>, and <b>maxT</b>.            Return the number of different patrol routes that satisfy these            criteria, modulo 1,000,000,007. Two routes are considered to be            different if there is a place that belongs to one of them, but does            not belong to the other one.         </td>       </tr>       <tr>         <td colspan="2"  >           <h3>             Definition           </h3>         </td>       </tr>       <tr>         <td>           &nbsp;&nbsp;&nbsp;&nbsp;         </td>         <td>           <table>             <tbody><tr>               <td>                 Class:               </td>               <td>                 PatrolRoute               </td>             </tr>             <tr>               <td>                 Method:               </td>               <td>                 countRoutes               </td>             </tr>             <tr>               <td>                 Parameters:               </td>               <td>                 int, int, int, int               </td>             </tr>             <tr>               <td>                 Returns:               </td>               <td>                 int               </td>             </tr>             <tr>               <td>                 Method signature:               </td>               <td>                 int countRoutes(int X, int Y, int minT, int maxT)               </td>             </tr>             <tr>               <td colspan="2"  >                 (be sure your method is public)               </td>             </tr>           </table>         </td>       </tr>       <tr>         <td>           &nbsp;&nbsp;&nbsp;&nbsp;         </td>       </tr>       <tr>         <td>                    </td>       </tr>       <tr>         <td colspan="2"  >           <h3>             Constraints           </h3>         </td>       </tr>       <tr>         <td valign="top"  align="center"  >           -         </td>         <td>           <b>X</b> and <b>Y</b> will each be between 3 and 4,000, inclusive.         </td>       </tr>       <tr>         <td valign="top"  align="center"  >           -         </td>         <td>           <b>minT</b> will be between 1 and 20,000, inclusive.         </td>       </tr>       <tr>         <td valign="top"  align="center"  >           -         </td>         <td>           <b>maxT</b> will be between <b>minT</b> and 20,000, inclusive.         <br><br><font size="4"  color="#0000ff"  ><b>950：</b></font><br><table>       <tbody><tr>         <td colspan="2"  >           <h3>             Problem Statement           </h3>         </td>       </tr>       <tr>         <td>           &nbsp;&nbsp;&nbsp;&nbsp;         </td>         <td>           <p>             A standard way of ordering words in a dictionary involves              comparison of two words character by character, from left to              right, until some two characters disagree. Jim thinks it's pretty              boring, so he introduced a more complicated and less predictable              scheme.           </p>           <p>                        </p>           <p>             Given is a String[] <b>words</b> that contains N distinct words              and each element is a single word. The length of each word is the              same -- exactly L characters. To order words according to his              scheme, Jim first generates a random permutation p[0], p[1], ...,              p[L-1] of integers between 0 and L-1, inclusive. This permutation              is generated only once and then considered to be fixed for the              rest of the procedure. Using the permutation p, Jim can compare              any two words as follows:           </p>           <p>                        </p>           <pre>// returns -1, if A&lt;B, 0, if A=B, and 1, if A&gt;B function Compare(Word A, Word B):  for i = 0, 1, ..., L-1:   a := character at position p[i] (0-based) in A   b := character at position p[i] (0-based) in B   if (a &lt; b), return -1   if (b &lt; a), return 1   return 0</pre>           <p>                        </p>           <p>             Let <i>Sorted</i> be the list of the given <b>words</b> ordered              according to Compare operator defined above. In other words,              Compare(<i>Sorted</i>[i], <i>Sorted</i>[j]) = -1, for any i, j, 0              &lt;= i &lt; j &lt; N. Let <i>pos</i>[i] be the 0-based position              of <b>words</b>[i] within <i>Sorted</i>.           </p>           <p>                        </p>           <p>             Obviously, the value <i>pos</i>[i] depends on the choice of the              random permutation p. Assume that p is chosen uniformly at random.              Return a double[] that contains N elements. Element i of the              return value must be the expected value of <i>pos</i>[i].           </p>         </td>       </tr>       <tr>         <td colspan="2"  >           <h3>             Definition           </h3>         </td>       </tr>       <tr>         <td>           &nbsp;&nbsp;&nbsp;&nbsp;         </td>         <td>           <table>             <tbody><tr>               <td>                 Class:               </td>               <td>                 StrangeDictionary               </td>             </tr>             <tr>               <td>                 Method:               </td>               <td>                 getExpectedPositions               </td>             </tr>             <tr>               <td>                 Parameters:               </td>               <td>                 String[]               </td>             </tr>             <tr>               <td>                 Returns:               </td>               <td>                 double[]               </td>             </tr>             <tr>               <td>                 Method signature:               </td>               <td>                 double[] getExpectedPositions(String[] words)               </td>             </tr>             <tr>               <td colspan="2"  >                 (be sure your method is public)               </td>             </tr>           </table>         </td>       </tr>       <tr>         <td>           &nbsp;&nbsp;&nbsp;&nbsp;         </td>       </tr>       <tr>         <td>                    </td>       </tr>       <tr>         <td colspan="2"  >           <h3>             Notes           </h3>         </td>       </tr>       <tr>         <td valign="top"  align="center"  >           -         </td>         <td>           Each element of the return value must have an absolute or relative            error of less than 1e-9.         </td>       </tr>       <tr>         <td colspan="2"  >           <h3>             Constraints           </h3>         </td>       </tr>       <tr>         <td valign="top"  align="center"  >           -         </td>         <td>           <b>words</b> will contain between 1 and 50 elements, inclusive.         </td>       </tr>       <tr>         <td valign="top"  align="center"  >           -         </td>         <td>           Each element of <b>words</b> will contain between 1 and 50            characters, inclusive.         </td>       </tr>       <tr>         <td valign="top"  align="center"  >           -         </td>         <td>           All elements of <b>words</b> will contain the same number of            characters.         </td>       </tr>       <tr>         <td valign="top"  align="center"  >           -         </td>         <td>           Each character in each element of <b>words</b> will be a lowercase            letter ('a'-'z').         </td>       </tr>       <tr>         <td valign="top"  align="center"  >           -         </td>         <td>           All elements of <b>words</b> will be distinct.         </td>       </tr>     </table></td>       </tr>     </table></td>       </tr>     </table></div><wbr></div>]]></description>
	    <author><![CDATA[long1]]></author>
	    <comments>http://blog.163.com/lfw2565295@126/blog/static/1220051620124904453272</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/lfw2565295@126/blog/static/1220051620124904453272</guid>
    <pubDate>Wed, 9 May 2012 12:44:53 +0800</pubDate>
    <dcterms:modified>2012-05-09T12:44:53+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[g++ diff]]></title>	
    <link>http://blog.163.com/lfw2565295@126/blog/static/1220051620124842437299</link>
    <description><![CDATA[<div><font size="4"  >g++ -o a a.cpp<br>time ./a &lt; a.in &gt;team.out<br>time ./a &lt;a2.in &gt;team.out<br>diff team.out a.out<br><br></font></div>]]></description>
	    <author><![CDATA[long1]]></author>
	    <comments>http://blog.163.com/lfw2565295@126/blog/static/1220051620124842437299</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/lfw2565295@126/blog/static/1220051620124842437299</guid>
    <pubDate>Tue, 8 May 2012 16:24:37 +0800</pubDate>
    <dcterms:modified>2012-05-08T16:24:37+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[37th ACM/ICPC 浙江师范大学邀请赛最终排名 PC^2 版本]]></title>	
    <link>http://blog.163.com/lfw2565295@126/blog/static/12200516201246115145725</link>
    <description><![CDATA[<div><table border="0"  style="font-family: Simsun;"  ><tbody><tr><th><strong><u>Rank</u></strong></th><th><strong><u>Name</u></strong></th><th><strong><u>Solved</u></strong></th><th><strong><u>Time</u></strong></th><th>&nbsp;&nbsp;&nbsp;&nbsp;<strong><u>A</u></strong>&nbsp;&nbsp;&nbsp;&nbsp;</th><th>&nbsp;&nbsp;&nbsp;&nbsp;<strong><u>B</u></strong>&nbsp;&nbsp;&nbsp;&nbsp;</th><th>&nbsp;&nbsp;&nbsp;&nbsp;<strong><u>C</u></strong>&nbsp;&nbsp;&nbsp;&nbsp;</th><th>&nbsp;&nbsp;&nbsp;&nbsp;<strong><u>D</u></strong>&nbsp;&nbsp;&nbsp;&nbsp;</th><th>&nbsp;&nbsp;&nbsp;&nbsp;<strong><u>E</u></strong>&nbsp;&nbsp;&nbsp;&nbsp;</th><th>&nbsp;&nbsp;&nbsp;&nbsp;<strong><u>F</u></strong>&nbsp;&nbsp;&nbsp;&nbsp;</th><th>&nbsp;&nbsp;&nbsp;&nbsp;<strong><u>G</u></strong>&nbsp;&nbsp;&nbsp;&nbsp;</th><th>&nbsp;&nbsp;&nbsp;&nbsp;<strong><u>H</u></strong>&nbsp;&nbsp;&nbsp;&nbsp;</th><th>&nbsp;&nbsp;&nbsp;&nbsp;<strong><u>I</u></strong>&nbsp;&nbsp;&nbsp;&nbsp;</th><th>&nbsp;&nbsp;&nbsp;&nbsp;<strong><u>J</u></strong>&nbsp;&nbsp;&nbsp;&nbsp;</th><th>Total att/solv</th></tr><tr><td></td><td></td><td></td><td></td><td><center>Light_Green</center></td><td><center>Orange</center></td><td><center>Red</center></td><td><center>Light_Purple</center></td><td><center>Pink</center></td><td><center>White</center></td><td><center>Deep_Purple</center></td><td><center>Blue</center></td><td><center>Yellow</center></td><td><center>Deep_Green</center></td></tr><tr><td>1</td><td>Seraphim</td><td>8</td><td>967</td><td>2/19</td><td>1/46</td><td>1/216</td><td>2/94</td><td>2/56</td><td>1/101</td><td>3/183</td><td>0/--</td><td>1/152</td><td>0/--</td><td>13/8</td></tr><tr><td>2</td><td>Epic</td><td>8</td><td>1190</td><td>2/38</td><td>1/30</td><td>1/197</td><td>2/77</td><td>1/83</td><td>1/192</td><td>4/219</td><td>0/--</td><td>2/234</td><td>0/--</td><td>14/8</td></tr><tr><td>3</td><td>FreeJourney</td><td>6</td><td>631</td><td>1/40</td><td>2/28</td><td>1/195</td><td>2/129</td><td>1/57</td><td>2/122</td><td>1/--</td><td>0/--</td><td>9/--</td><td>0/--</td><td>19/6</td></tr><tr><td>4</td><td>kerokero</td><td>6</td><td>866</td><td>3/59</td><td>1/41</td><td>1/--</td><td>1/73</td><td>1/113</td><td>7/262</td><td>7/--</td><td>0/--</td><td>2/138</td><td>0/--</td><td>23/6</td></tr><tr><td>5</td><td>FutureGazer</td><td>6</td><td>895</td><td>2/31</td><td>1/54</td><td>13/--</td><td>1/130</td><td>2/64</td><td>2/233</td><td>0/--</td><td>0/--</td><td>5/243</td><td>0/--</td><td>26/6</td></tr><tr><td>6</td><td>Cutit</td><td>6</td><td>1047</td><td>1/24</td><td>2/100</td><td>25/--</td><td>1/48</td><td>6/253</td><td>3/277</td><td>0/--</td><td>0/--</td><td>1/185</td><td>0/--</td><td>39/6</td></tr><tr><td>7</td><td>EndlessMaze</td><td>6</td><td>1151</td><td>1/81</td><td>1/50</td><td>3/287</td><td>1/221</td><td>3/237</td><td>1/195</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>10/6</td></tr><tr><td>8</td><td>Simpler</td><td>5</td><td>610</td><td>2/75</td><td>1/43</td><td>1/97</td><td>1/160</td><td>2/195</td><td>0/--</td><td>0/--</td><td>0/--</td><td>1/--</td><td>0/--</td><td>8/5</td></tr><tr><td>9</td><td>YXC</td><td>5</td><td>709</td><td>2/42</td><td>1/68</td><td>1/126</td><td>2/98</td><td>4/275</td><td>1/--</td><td>1/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>12/5</td></tr><tr><td>10</td><td>Freshman</td><td>5</td><td>794</td><td>1/75</td><td>3/114</td><td>1/167</td><td>3/191</td><td>3/127</td><td>1/--</td><td>0/--</td><td>0/--</td><td>5/--</td><td>0/--</td><td>17/5</td></tr><tr><td>11</td><td>HUST_Godot</td><td>5</td><td>933</td><td>1/42</td><td>2/190</td><td>0/--</td><td>1/194</td><td>4/120</td><td>3/267</td><td>0/--</td><td>0/--</td><td>4/--</td><td>0/--</td><td>15/5</td></tr><tr><td>12</td><td>TimeBomb</td><td>5</td><td>1152</td><td>8/162</td><td>3/89</td><td>2/138</td><td>1/202</td><td>5/281</td><td>0/--</td><td>0/--</td><td>0/--</td><td>6/--</td><td>0/--</td><td>25/5</td></tr><tr><td>13</td><td>Mercury</td><td>4</td><td>359</td><td>1/29</td><td>1/61</td><td>0/--</td><td>2/97</td><td>2/132</td><td>0/--</td><td>4/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>10/4</td></tr><tr><td>14</td><td>HDU-Baiye</td><td>4</td><td>370</td><td>2/62</td><td>2/80</td><td>9/--</td><td>1/45</td><td>2/123</td><td>0/--</td><td>0/--</td><td>0/--</td><td>2/--</td><td>0/--</td><td>18/4</td></tr><tr><td>15</td><td>HDU-FinalChance</td><td>4</td><td>380</td><td>1/32</td><td>1/68</td><td>4/--</td><td>2/102</td><td>1/158</td><td>0/--</td><td>0/--</td><td>0/--</td><td>1/--</td><td>0/--</td><td>10/4</td></tr><tr><td>16</td><td>ZSTU_02</td><td>4</td><td>393</td><td>1/33</td><td>1/64</td><td>3/--</td><td>1/152</td><td>2/124</td><td>3/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>11/4</td></tr><tr><td>17</td><td>C3S</td><td>4</td><td>436</td><td>1/35</td><td>2/62</td><td>0/--</td><td>4/171</td><td>1/88</td><td>0/--</td><td>0/--</td><td>0/--</td><td>4/--</td><td>0/--</td><td>12/4</td></tr><tr><td>18</td><td>N.N.Update</td><td>4</td><td>502</td><td>1/30</td><td>1/97</td><td>3/--</td><td>1/176</td><td>1/199</td><td>2/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>9/4</td></tr><tr><td>19</td><td>UESTC_Excalibur</td><td>4</td><td>612</td><td>2/30</td><td>1/62</td><td>3/--</td><td>1/87</td><td>10/233</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>17/4</td></tr><tr><td>20</td><td>Tour_de_Force</td><td>4</td><td>635</td><td>2/101</td><td>1/96</td><td>3/--</td><td>3/200</td><td>1/178</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>10/4</td></tr><tr><td>21</td><td>GanSiDui</td><td>4</td><td>668</td><td>1/31</td><td>3/102</td><td>2/--</td><td>1/254</td><td>16/--</td><td>1/241</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>24/4</td></tr><tr><td>22</td><td>xiaoshua</td><td>4</td><td>690</td><td>1/23</td><td>1/116</td><td>0/--</td><td>2/216</td><td>4/255</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>8/4</td></tr><tr><td>23</td><td>Vector</td><td>4</td><td>698</td><td>1/39</td><td>2/154</td><td>0/--</td><td>5/229</td><td>1/176</td><td>14/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>23/4</td></tr><tr><td>24</td><td>Aiwell</td><td>4</td><td>719</td><td>2/53</td><td>3/149</td><td>0/--</td><td>5/245</td><td>2/112</td><td>6/--</td><td>0/--</td><td>0/--</td><td>3/--</td><td>0/--</td><td>21/4</td></tr><tr><td>25</td><td>primeShark</td><td>4</td><td>723</td><td>2/81</td><td>1/94</td><td>6/--</td><td>2/184</td><td>5/244</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>16/4</td></tr><tr><td>26</td><td>AxorB</td><td>4</td><td>733</td><td>4/137</td><td>3/104</td><td>4/--</td><td>2/212</td><td>1/160</td><td>1/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>15/4</td></tr><tr><td>27</td><td>Nyquist</td><td>4</td><td>761</td><td>1/44</td><td>3/124</td><td>0/--</td><td>3/277</td><td>2/216</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>9/4</td></tr><tr><td>28</td><td>galaxy</td><td>4</td><td>789</td><td>1/103</td><td>2/88</td><td>0/--</td><td>2/244</td><td>3/274</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>8/4</td></tr><tr><td>29</td><td>Water</td><td>4</td><td>933</td><td>1/34</td><td>10/241</td><td>0/--</td><td>2/284</td><td>2/154</td><td>1/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>16/4</td></tr><tr><td>30</td><td>TeammateKiller</td><td>4</td><td>938</td><td>3/91</td><td>1/102</td><td>0/--</td><td>6/259</td><td>4/286</td><td>1/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>15/4</td></tr><tr><td>31</td><td>NJU_Diablo</td><td>4</td><td>1037</td><td>4/226</td><td>4/142</td><td>0/--</td><td>2/297</td><td>1/232</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>11/4</td></tr><tr><td>32</td><td>ZJUT-3</td><td>4</td><td>1047</td><td>4/113</td><td>5/297</td><td>0/--</td><td>3/184</td><td>2/253</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>14/4</td></tr><tr><td>33</td><td>CSU_BMW</td><td>3</td><td>236</td><td>1/32</td><td>1/114</td><td>4/--</td><td>1/90</td><td>5/--</td><td>1/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>13/3</td></tr><tr><td>34</td><td>Accelerator</td><td>3</td><td>236</td><td>1/30</td><td>1/75</td><td>0/--</td><td>2/--</td><td>1/131</td><td>0/--</td><td>0/--</td><td>0/--</td><td>1/--</td><td>5/--</td><td>11/3</td></tr><tr><td>35</td><td>HIT_Avalon</td><td>3</td><td>279</td><td>2/71</td><td>2/51</td><td>0/--</td><td>1/117</td><td>10/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>5/--</td><td>0/--</td><td>20/3</td></tr><tr><td>36</td><td>Memory</td><td>3</td><td>312</td><td>1/51</td><td>2/82</td><td>0/--</td><td>1/159</td><td>4/--</td><td>1/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>9/3</td></tr><tr><td>37</td><td>ZJUT-1</td><td>3</td><td>347</td><td>2/79</td><td>2/90</td><td>2/--</td><td>1/138</td><td>11/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>18/3</td></tr><tr><td>38</td><td>ZSTU_01</td><td>3</td><td>398</td><td>2/42</td><td>2/119</td><td>0/--</td><td>2/177</td><td>13/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>19/3</td></tr><tr><td>39</td><td>NKU_HOT ~Encore~</td><td>3</td><td>402</td><td>1/29</td><td>1/147</td><td>3/--</td><td>0/--</td><td>2/--</td><td>3/186</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>10/3</td></tr><tr><td>40</td><td>WDM</td><td>3</td><td>407</td><td>1/52</td><td>2/105</td><td>0/--</td><td>14/--</td><td>4/170</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>21/3</td></tr><tr><td>41</td><td>ZSTU_03</td><td>3</td><td>416</td><td>1/45</td><td>1/71</td><td>0/--</td><td>2/--</td><td>4/240</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>8/3</td></tr><tr><td>42</td><td>HDU-Overflow</td><td>3</td><td>455</td><td>1/46</td><td>2/120</td><td>0/--</td><td>1/269</td><td>3/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>7/3</td></tr><tr><td>43</td><td>HDU-Alaligehua</td><td>3</td><td>462</td><td>1/32</td><td>3/186</td><td>1/--</td><td>3/164</td><td>11/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>19/3</td></tr><tr><td>44</td><td>ham</td><td>3</td><td>480</td><td>1/63</td><td>2/158</td><td>0/--</td><td>0/--</td><td>2/219</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>5/3</td></tr><tr><td>45</td><td>Yababom</td><td>3</td><td>480</td><td>2/69</td><td>2/103</td><td>6/--</td><td>3/228</td><td>10/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>23/3</td></tr><tr><td>46</td><td>NJU_Atom</td><td>3</td><td>482</td><td>1/51</td><td>2/197</td><td>0/--</td><td>0/--</td><td>2/194</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>5/3</td></tr><tr><td>47</td><td>Ceaseless</td><td>3</td><td>483</td><td>1/51</td><td>2/199</td><td>0/--</td><td>4/--</td><td>1/213</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>8/3</td></tr><tr><td>48</td><td>Bomb</td><td>3</td><td>484</td><td>1/27</td><td>2/146</td><td>7/--</td><td>0/--</td><td>2/271</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>12/3</td></tr><tr><td>49</td><td>NKU_COLD</td><td>3</td><td>486</td><td>1/34</td><td>1/149</td><td>2/--</td><td>2/--</td><td>4/243</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>10/3</td></tr><tr><td>50</td><td>NKU_Code Monkey</td><td>3</td><td>487</td><td>1/25</td><td>1/83</td><td>2/--</td><td>1/--</td><td>5/299</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>10/3</td></tr><tr><td>51</td><td>fly_CFE</td><td>3</td><td>509</td><td>2/74</td><td>1/216</td><td>0/--</td><td>3/159</td><td>3/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>9/3</td></tr><tr><td>52</td><td>Star_Light</td><td>3</td><td>515</td><td>1/117</td><td>3/139</td><td>0/--</td><td>6/--</td><td>2/199</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>12/3</td></tr><tr><td>53</td><td>ZJUT-2</td><td>3</td><td>517</td><td>2/82</td><td>1/215</td><td>0/--</td><td>2/180</td><td>4/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>9/3</td></tr><tr><td>54</td><td>Maze</td><td>3</td><td>531</td><td>2/61</td><td>3/183</td><td>11/--</td><td>0/--</td><td>1/227</td><td>6/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>23/3</td></tr><tr><td>55</td><td>ZSTU_04</td><td>3</td><td>550</td><td>1/59</td><td>1/192</td><td>0/--</td><td>1/--</td><td>2/279</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>5/3</td></tr><tr><td>56</td><td>shrimp</td><td>3</td><td>554</td><td>1/47</td><td>2/183</td><td>0/--</td><td>0/--</td><td>2/284</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>5/3</td></tr><tr><td>57</td><td>ZAFU_2</td><td>3</td><td>584</td><td>1/32</td><td>2/114</td><td>0/--</td><td>0/--</td><td>9/258</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>12/3</td></tr><tr><td>58</td><td>Burning Ice</td><td>3</td><td>592</td><td>1/62</td><td>5/246</td><td>0/--</td><td>4/--</td><td>3/164</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>13/3</td></tr><tr><td>59</td><td>Tangent</td><td>3</td><td>600</td><td>1/45</td><td>3/247</td><td>5/--</td><td>0/--</td><td>2/248</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>11/3</td></tr><tr><td>60</td><td>HDU-ACHunter</td><td>3</td><td>608</td><td>1/42</td><td>3/--</td><td>7/--</td><td>2/215</td><td>6/231</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>19/3</td></tr><tr><td>61</td><td>ZCMU-BS-Forever</td><td>3</td><td>633</td><td>3/135</td><td>3/184</td><td>0/--</td><td>0/--</td><td>1/234</td><td>1/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>8/3</td></tr><tr><td>62</td><td>Jxust_leap</td><td>3</td><td>666</td><td>3/90</td><td>2/142</td><td>0/--</td><td>6/274</td><td>1/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>12/3</td></tr><tr><td>63</td><td>XYZSOY</td><td>3</td><td>670</td><td>1/40</td><td>4/233</td><td>0/--</td><td>3/297</td><td>2/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>10/3</td></tr><tr><td>64</td><td>JLU3</td><td>3</td><td>681</td><td>1/108</td><td>2/56</td><td>0/--</td><td>0/--</td><td>11/297</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>14/3</td></tr><tr><td>65</td><td>HFUT_Evolution</td><td>3</td><td>691</td><td>1/83</td><td>2/171</td><td>8/277</td><td>0/--</td><td>12/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>23/3</td></tr><tr><td>66</td><td>GDUT_Twilight</td><td>3</td><td>734</td><td>1/58</td><td>5/247</td><td>0/--</td><td>4/289</td><td>8/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>18/3</td></tr><tr><td>67</td><td>UESTC_silence</td><td>3</td><td>738</td><td>1/63</td><td>9/299</td><td>0/--</td><td>1/216</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>11/3</td></tr><tr><td>68</td><td>Rookies Back</td><td>2</td><td>176</td><td>2/45</td><td>1/111</td><td>0/--</td><td>0/--</td><td>7/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>10/2</td></tr><tr><td>69</td><td>Ecust_ChallengeSyste</td><td>2</td><td>177</td><td>1/30</td><td>2/127</td><td>0/--</td><td>0/--</td><td>13/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>16/2</td></tr><tr><td>70</td><td>SmokeWine</td><td>2</td><td>284</td><td>1/75</td><td>0/--</td><td>0/--</td><td>0/--</td><td>1/209</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>2/2</td></tr><tr><td>71</td><td>Simple</td><td>2</td><td>288</td><td>1/37</td><td>2/--</td><td>4/--</td><td>0/--</td><td>1/251</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>8/2</td></tr><tr><td>72</td><td>Ldream</td><td>2</td><td>293</td><td>1/42</td><td>7/--</td><td>0/--</td><td>0/--</td><td>3/211</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>11/2</td></tr><tr><td>73</td><td>Front</td><td>2</td><td>295</td><td>1/91</td><td>2/184</td><td>5/--</td><td>0/--</td><td>10/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>18/2</td></tr><tr><td>74</td><td>DIGIMON</td><td>2</td><td>312</td><td>1/122</td><td>2/--</td><td>0/--</td><td>0/--</td><td>1/190</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>4/2</td></tr><tr><td>75</td><td>#____#</td><td>2</td><td>323</td><td>1/49</td><td>0/--</td><td>0/--</td><td>0/--</td><td>2/254</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>3/2</td></tr><tr><td>76</td><td>Paralines Zero</td><td>2</td><td>323</td><td>1/28</td><td>3/255</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>4/2</td></tr><tr><td>77</td><td>Mars</td><td>2</td><td>331</td><td>3/84</td><td>2/187</td><td>0/--</td><td>2/--</td><td>0/--</td><td>1/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>8/2</td></tr><tr><td>78</td><td>NKU_22DormB306</td><td>2</td><td>378</td><td>3/79</td><td>4/199</td><td>0/--</td><td>1/--</td><td>2/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>10/2</td></tr><tr><td>79</td><td>NKU_CHH</td><td>2</td><td>387</td><td>2/91</td><td>2/256</td><td>0/--</td><td>3/--</td><td>5/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>12/2</td></tr><tr><td>80</td><td>SuperBug</td><td>2</td><td>388</td><td>1/102</td><td>2/266</td><td>1/--</td><td>2/--</td><td>12/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>18/2</td></tr><tr><td>81</td><td>xiaocaicai</td><td>2</td><td>393</td><td>1/34</td><td>0/--</td><td>0/--</td><td>7/239</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>1/--</td><td>9/2</td></tr><tr><td>82</td><td>Badminton</td><td>2</td><td>403</td><td>2/110</td><td>0/--</td><td>0/--</td><td>0/--</td><td>1/273</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>3/2</td></tr><tr><td>83</td><td>iBeyond</td><td>2</td><td>406</td><td>3/127</td><td>1/239</td><td>0/--</td><td>3/--</td><td>0/--</td><td>1/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>8/2</td></tr><tr><td>84</td><td>come on baby</td><td>2</td><td>461</td><td>6/180</td><td>2/161</td><td>0/--</td><td>0/--</td><td>1/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>9/2</td></tr><tr><td>85</td><td>MaXon</td><td>2</td><td>499</td><td>3/249</td><td>0/--</td><td>0/--</td><td>3/--</td><td>1/210</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>7/2</td></tr><tr><td>86</td><td>Lost</td><td>2</td><td>644</td><td>8/267</td><td>2/217</td><td>0/--</td><td>0/--</td><td>2/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>12/2</td></tr><tr><td>87</td><td>Killers</td><td>1</td><td>51</td><td>1/51</td><td>0/--</td><td>0/--</td><td>0/--</td><td>3/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>4/1</td></tr><tr><td>88</td><td>Scarlet_RE</td><td>1</td><td>62</td><td>1/62</td><td>1/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>2/1</td></tr><tr><td>89</td><td>ZCMU-breeze（1）</td><td>1</td><td>65</td><td>1/65</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>1/1</td></tr><tr><td>90</td><td>Unicorn</td><td>1</td><td>76</td><td>1/76</td><td>0/--</td><td>0/--</td><td>3/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>4/1</td></tr><tr><td>91</td><td>hutc_C_man</td><td>1</td><td>87</td><td>1/87</td><td>1/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>1/--</td><td>0/--</td><td>0/--</td><td>3/1</td></tr><tr><td>92</td><td>ACDarkStar</td><td>1</td><td>90</td><td>2/70</td><td>3/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>5/1</td></tr><tr><td>93</td><td>JxufeAAA</td><td>1</td><td>90</td><td>1/90</td><td>0/--</td><td>0/--</td><td>3/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>4/1</td></tr><tr><td>94</td><td>HDU-Diligence</td><td>1</td><td>100</td><td>2/80</td><td>0/--</td><td>0/--</td><td>0/--</td><td>7/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>9/1</td></tr><tr><td>95</td><td>Sun_Light</td><td>1</td><td>109</td><td>2/89</td><td>4/--</td><td>0/--</td><td>1/--</td><td>7/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>14/1</td></tr><tr><td>96</td><td>BITelite</td><td>1</td><td>111</td><td>1/111</td><td>0/--</td><td>0/--</td><td>2/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>8/--</td><td>0/--</td><td>11/1</td></tr><tr><td>97</td><td>1+1+1&gt;3</td><td>1</td><td>115</td><td>1/115</td><td>0/--</td><td>2/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>3/1</td></tr><tr><td>98</td><td>Bnuz_EyesOnMe_</td><td>1</td><td>124</td><td>2/104</td><td>0/--</td><td>0/--</td><td>0/--</td><td>3/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>5/1</td></tr><tr><td>99</td><td>Surprising</td><td>1</td><td>142</td><td>1/142</td><td>0/--</td><td>0/--</td><td>3/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>4/1</td></tr><tr><td>100</td><td>vampire</td><td>1</td><td>146</td><td>2/126</td><td>0/--</td><td>0/--</td><td>2/--</td><td>6/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>10/1</td></tr><tr><td>101</td><td>Flyhw</td><td>1</td><td>163</td><td>3/123</td><td>7/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>10/1</td></tr><tr><td>102</td><td>HWJ</td><td>1</td><td>168</td><td>3/128</td><td>0/--</td><td>5/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>8/1</td></tr><tr><td>103</td><td>Extreme</td><td>1</td><td>199</td><td>4/139</td><td>0/--</td><td>0/--</td><td>2/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>6/1</td></tr><tr><td>104</td><td>BJZCMU-A + B</td><td>1</td><td>207</td><td>6/107</td><td>2/--</td><td>0/--</td><td>1/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>9/1</td></tr><tr><td>105</td><td>ZSTU_05</td><td>1</td><td>213</td><td>1/213</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>1/1</td></tr><tr><td>106</td><td>Moon_Light</td><td>1</td><td>218</td><td>2/198</td><td>3/--</td><td>2/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>7/1</td></tr><tr><td>107</td><td>HUST_Ignotus</td><td>1</td><td>228</td><td>4/168</td><td>2/--</td><td>0/--</td><td>2/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>8/1</td></tr><tr><td>108</td><td>JxufeRandom</td><td>1</td><td>238</td><td>3/198</td><td>0/--</td><td>0/--</td><td>3/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>6/1</td></tr><tr><td>109</td><td>Here Idears Come</td><td>1</td><td>245</td><td>2/225</td><td>0/--</td><td>0/--</td><td>3/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>5/1</td></tr><tr><td>110</td><td>JLU1</td><td>1</td><td>247</td><td>2/227</td><td>0/--</td><td>5/--</td><td>8/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>15/1</td></tr><tr><td>111</td><td>Earth</td><td>1</td><td>253</td><td>1/253</td><td>2/--</td><td>0/--</td><td>3/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>6/1</td></tr><tr><td>112</td><td>JLU2</td><td>1</td><td>276</td><td>2/256</td><td>0/--</td><td>2/--</td><td>1/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>5/1</td></tr><tr><td>113</td><td>Try</td><td>1</td><td>282</td><td>6/--</td><td>4/--</td><td>0/--</td><td>1/--</td><td>1/282</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>12/1</td></tr><tr><td>114</td><td>zjicm:echo1</td><td>1</td><td>308</td><td>4/248</td><td>2/--</td><td>1/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>7/1</td></tr><tr><td>115</td><td>Romance</td><td>1</td><td>331</td><td>6/231</td><td>1/--</td><td>9/--</td><td>0/--</td><td>7/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>23/1</td></tr><tr><td>116</td><td>SuperSoy</td><td>1</td><td>339</td><td>4/279</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>4/1</td></tr><tr><td>117</td><td>hutc_AC^3</td><td>1</td><td>495</td><td>12/275</td><td>1/--</td><td>1/--</td><td>1/--</td><td>13/--</td><td>13/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>41/1</td></tr><tr><td>118</td><td>CoreCoder</td><td>0</td><td>0</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/0</td></tr><tr><td>118</td><td>Dream</td><td>0</td><td>0</td><td>4/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>4/0</td></tr><tr><td>118</td><td>JZS'fight</td><td>0</td><td>0</td><td>5/--</td><td>0/--</td><td>0/--</td><td>1/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>6/0</td></tr><tr><td>118</td><td>LittleGirl</td><td>0</td><td>0</td><td>0/--</td><td>6/--</td><td>0/--</td><td>1/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>7/0</td></tr><tr><td>118</td><td>ZAFU_1</td><td>0</td><td>0</td><td>5/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>0/--</td><td>5/0</td></tr><tr><th><strong><u>Rank</u></strong></th><th><strong><u>Name</u></strong></th><th><strong><u>Solved</u></strong></th><th><strong><u>Time</u></strong></th><th>&nbsp;&nbsp;&nbsp;&nbsp;<strong><u>A</u></strong>&nbsp;&nbsp;&nbsp;&nbsp;</th><th>&nbsp;&nbsp;&nbsp;&nbsp;<strong><u>B</u></strong>&nbsp;&nbsp;&nbsp;&nbsp;</th><th>&nbsp;&nbsp;&nbsp;&nbsp;<strong><u>C</u></strong>&nbsp;&nbsp;&nbsp;&nbsp;</th><th>&nbsp;&nbsp;&nbsp;&nbsp;<strong><u>D</u></strong>&nbsp;&nbsp;&nbsp;&nbsp;</th><th>&nbsp;&nbsp;&nbsp;&nbsp;<strong><u>E</u></strong>&nbsp;&nbsp;&nbsp;&nbsp;</th><th>&nbsp;&nbsp;&nbsp;&nbsp;<strong><u>F</u></strong>&nbsp;&nbsp;&nbsp;&nbsp;</th><th>&nbsp;&nbsp;&nbsp;&nbsp;<strong><u>G</u></strong>&nbsp;&nbsp;&nbsp;&nbsp;</th><th>&nbsp;&nbsp;&nbsp;&nbsp;<strong><u>H</u></strong>&nbsp;&nbsp;&nbsp;&nbsp;</th><th>&nbsp;&nbsp;&nbsp;&nbsp;<strong><u>I</u></strong>&nbsp;&nbsp;&nbsp;&nbsp;</th><th>&nbsp;&nbsp;&nbsp;&nbsp;<strong><u>J</u></strong>&nbsp;&nbsp;&nbsp;&nbsp;</th><th>Total att/solv</th></tr><tr><td></td><td></td><td></td><td></td><td><center>Light_Green</center></td><td><center>Orange</center></td><td><center>Red</center></td><td><center>Light_Purple</center></td><td><center>Pink</center></td><td><center>White</center></td><td><center>Deep_Purple</center></td><td><center>Blue</center></td><td><center>Yellow</center></td><td><center>Deep_Green</center></td></tr><tr><td></td><td>Submitted/1st Yes/Total Yes</td><td></td><td></td><td>248/19/116</td><td>222/28/77</td><td>182/97/9</td><td>200/45/48</td><td>369/56/58</td><td>78/101/10</td><td>20/183/2</td><td>1/--/0</td><td>60/138/5</td><td>6/--/0</td><td>1386/325</td></tr></table><p style="font-family: Simsun; line-height: normal; text-align: -webkit-auto; font-size: medium;"  >Created by&nbsp;<a rel="nofollow" href="http://www.ecs.csus.edu/pc2"  >CSUS PC^2 9.2.1 20120304 build 2482</a>&nbsp;<br><a rel="nofollow" href="http://www.ecs.csus.edu/pc2/"  >http://www.ecs.csus.edu/pc2/</a>&nbsp;<br>Last updated Sun May 06 14:11:22 CST 2012</p><wbr></div>]]></description>
	    <author><![CDATA[long1]]></author>
	    <comments>http://blog.163.com/lfw2565295@126/blog/static/12200516201246115145725</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/lfw2565295@126/blog/static/12200516201246115145725</guid>
    <pubDate>Sun, 6 May 2012 23:51:45 +0800</pubDate>
    <dcterms:modified>2012-05-06T23:51:45+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[shell编程练习题1]]></title>	
    <link>http://blog.163.com/lfw2565295@126/blog/static/122005162012436197458</link>
    <description><![CDATA[<div><div><b><font color="#0000ff"  size="4"  >一．用Shell编程，判断一文件是不是字符设备文件，如果是将其拷贝到 /dev 目录下。</font></b></div><div>参考程序：</div><div>#!/bin/sh</div><div>FILENAME=</div><div>echo “Input file name：”</div><div>read FILENAME</div><div>if [ -c "$FILENAME" ]</div><div>then</div><div>cp $FILENAME /dev</div><div>fi</div><div><br></div><div><b><font color="#0000ff"  >five file type in linux: regular file, link file , directory file, device file(charater or block), pipe file</font></b></div><div><b><font color="#0000ff"  >unix这类系统里面分为character device and block device,像鼠标显示器键盘这类的一个个字节读取的称为字符设备，硬盘这类最小以扇区为单位，必须一次读512字节的称为块设备</font></b></div><div>普通文件都是字符流的，可以一个字节读取，硬盘设备一次至少读512字符，所以需要缓冲</div><div><font color="#0000ff"  ><b>使用ls -l查看，可以看到 crw------- 这样的描述，第一c表示字符设备文件；b表示块设备文件；d表示文件夹，也就是目录；一般文件第一个是"-"。后面三个“只读“，”写“，“执行”分别是属主权限u，组权限g，其它权限o</b></font></div><div><br></div><div>类似操作，桌面上有a文件和dira文件夹</div><div>写个a.sh把a文件移动到dira文件夹里</div><div>a.sh:</div><div>#! /bin/bash</div><div>FILENAME= &nbsp;#这个貌似可有可没有</div><div>echo "input file name:"</div><div>read FILENAME</div><div>if [ -e "$FILENAME" ]</div><div>then</div><div>mv $FILENAME dira</div><div>fi</div><div><br></div><div>chmod +x a.sh 让a.sh能执行</div><div>long1lfw@ubuntu:~/桌面$ ./a.sh</div><div>input file name:</div><div>a</div><div>运行下就能把a移动到dira里了</div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >(long1&nbsp;vs&nbsp;longpo&nbsp;转载请注明出处：</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px;"  ><a style="color: rgb(80, 80, 80); text-decoration: none; " href="http://blog.163.com/lfw2565295@126"  ><span style="line-height: 25px; color: rgb(0, 0, 255); text-decoration: underline; font-size: 10.5pt; font-family: 宋体;"  >http://blog.163.com/lfw2565295@126</span></a></span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >)</span></div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  ><br></span></div><div><font size="4"  color="#0000ff"  ><b>二. 写一个使用"case"的脚本，如果输入"start"能执行脚本a.sh,输入"cat"能查看a.sh</b></font></div><div>vim case.sh</div><div>#! /bin/bash</div><div>case "$1" in</div><div>'start')</div><div>cd ~/桌面; ./a.sh ;;</div><div>'view')</div><div>cd ~/桌面; cat a.sh;;</div><div>*)</div><div>&nbsp;echo "no such command usage $0 start|view";;</div><div>esac</div><div><br></div><div>注意，一行里多个命令用";" 分隔，一行只有一个命令，可以不用“;”，$1表示第一个参数，$0表示怎么执行的</div><div>运行：</div><div>long1lfw@ubuntu:~/桌面$ ./case.sh start</div><div>input file name:</div><div>a</div><div>long1lfw@ubuntu:~/桌面$ ./case.sh view</div><div>#! /bin/bash</div><div>echo "input file name:"</div><div>read FILENAME</div><div>if [ -e "$FILENAME" ]</div><div>then</div><div>mv $FILENAME dira</div><div>fi</div><div>long1lfw@ubuntu:~/桌面$ ./case.sh kao</div><div><div>no such command usage ./case.sh start|view</div></div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >(long1&nbsp;vs&nbsp;longpo&nbsp;转载请注明出处：</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px;"  ><a style="color: rgb(80, 80, 80); text-decoration: none; " href="http://blog.163.com/lfw2565295@126"  ><span style="line-height: 25px; color: rgb(0, 0, 255); text-decoration: underline; font-size: 10.5pt; font-family: 宋体;"  >http://blog.163.com/lfw2565295@126</span></a></span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >)</span></div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  ><br></span></div><div><font size="4"  color="#0000ff"  ><b>三．设计一个shell程序，添加一个新组为class1，然后添加属于这个组的30个用户，用户名的形式为stdxx，其中xx从01到30。</b></font></div><div>vim addclass1.sh</div><div>#!/bin/sh&nbsp;</div><div>i=1</div><div>groupadd class1</div><div>while [ $i -le 30 ]</div><div>do</div><div>if [ $i -le 9 ] ;then</div><div>USERNAME=stu0${i}</div><div>else</div><div>USERNAME=stu${i}</div><div>fi</div><div>useradd $USERNAME&nbsp;</div><div><b><font color="#0000ff"  >(echo $USERNAME; sleep 1; echo $USERNAME) | passwd $USERNAME</font></b></div><div><b><font color="#0000ff"  ><br></font></b></div><div><b><font color="#0000ff"  >#另外一种方法貌似不行</font></b></div><div><b><font color="#0000ff"  >#echo $USERNAME | passwd $USERNAME --stdin &gt; /dev/null 2&gt;&amp;1</font></b></div><div><br></div><div>mkdir /home/$USERNAME</div><div><font color="#0000ff"  ><b>chown</b></font> -R $USERNAME /home/$USERNAME</div><div><font color="#0000ff"  ><b>chgrp</b></font> -R class1 /home/$USERNAME&nbsp;</div><div><font color="#0000ff"  ><b>i=$(($i+1))</b></font></div><div>done</div><div><br></div><div><br></div><div>long1lfw@ubuntu:~/桌面$ chmod +x addclass1.sh</div><div>long1lfw@ubuntu:~/桌面$ ./addclass1.sh</div><div>注意不能直接运行，权限不够，需要 sudo ./addclass1.sh</div><div><br></div><div>关于创建，修改，删除，查看用户和用户组：</div><div>1，创建组</div><div>groupadd test</div><div>增加一个test组</div><div>2，修改组</div><div>groupmod -n test2 test</div><div>将test组的名子改成test2</div><div>3，删除组</div><div>groupdel test2</div><div>删除 组test2</div><div>4.查看组(a)查看当前登录用户所在的组 groups，查看lfw所在组 groups lfw (b)查看所有组 cat /etc/group</div><div><br></div><div>1.增加用户 useradd test</div><div>passwd test</div><div>增加用户test，有一点要注意的，useradd增加一个用户后，不要忘了给他设置密码，不然不能登录的。</div><div>2，修改用户</div><div>usermod -d /home/test -G test2 test</div><div>将test用户的登录目录改成/home/test，并加入test2组，注意这里是大G。</div><div>3，删除用户</div><div>userdel test</div><div>将test用户删除</div><div>4.查看用户 w 或 who 或 whoami 等</div><div><br></div><div>写一个相应删除组和用户的shell:</div><div>long1lfw@ubuntu:~/桌面$ vim delclass1.sh&nbsp;</div><div>#! /bin/bash</div><div>i=1</div><div>groupdel class1</div><div>while [ $i -le 30 ]</div><div>do</div><div>if [ $i -le 9 ]</div><div>then</div><div>USERNAME=stu0${i}</div><div>else</div><div>USERNAME=stu${i}</div><div>fi</div><div>userdel $USERNAME</div><div><font color="#0000ff"  ><b>rm -rf /home/$USERNAME</b></font></div><div><b><font color="#0000ff"  >i=$(($i+1))</font></b></div><div>done</div><div><br></div><div>同样，也需要chmod +x 以及 sudo运行</div><div>先执行sudo ./addclass1.sh</div><div>long1lfw@ubuntu:~/桌面$ sudo ./addclass1.sh</div><div>输入新的 UNIX 密码： 重新输入新的 UNIX 密码： passwd：已成功更新密码</div><div>输入新的 UNIX 密码： 重新输入新的 UNIX 密码： passwd：已成功更新密码</div><div>输入新的 UNIX 密码： 重新输入新的 UNIX 密码： passwd：已成功更新密码</div><div>输入新的 UNIX 密码： 重新输入新的 UNIX 密码： passwd：已成功更新密码</div><div>输入新的 UNIX 密码： 重新输入新的 UNIX 密码： passwd：已成功更新密码</div><div>输入新的 UNIX 密码： 重新输入新的 UNIX 密码： passwd：已成功更新密码</div><div>输入新的 UNIX 密码： 重新输入新的 UNIX 密码： passwd：已成功更新密码</div><div>输入新的 UNIX 密码： 重新输入新的 UNIX 密码： passwd：已成功更新密码</div><div>输入新的 UNIX 密码： 重新输入新的 UNIX 密码： passwd：已成功更新密码</div><div>输入新的 UNIX 密码： 重新输入新的 UNIX 密码： passwd：已成功更新密码</div><div>输入新的 UNIX 密码： 重新输入新的 UNIX 密码： passwd：已成功更新密码</div><div>输入新的 UNIX 密码： 重新输入新的 UNIX 密码： passwd：已成功更新密码</div><div>输入新的 UNIX 密码： 重新输入新的 UNIX 密码： passwd：已成功更新密码</div><div>输入新的 UNIX 密码： 重新输入新的 UNIX 密码： passwd：已成功更新密码</div><div>输入新的 UNIX 密码： 重新输入新的 UNIX 密码： passwd：已成功更新密码</div><div>输入新的 UNIX 密码： 重新输入新的 UNIX 密码： passwd：已成功更新密码</div><div>输入新的 UNIX 密码： 重新输入新的 UNIX 密码： passwd：已成功更新密码</div><div>输入新的 UNIX 密码： 重新输入新的 UNIX 密码： passwd：已成功更新密码</div><div>输入新的 UNIX 密码： 重新输入新的 UNIX 密码： passwd：已成功更新密码</div><div>输入新的 UNIX 密码： 重新输入新的 UNIX 密码： passwd：已成功更新密码</div><div>输入新的 UNIX 密码： 重新输入新的 UNIX 密码： passwd：已成功更新密码</div><div>输入新的 UNIX 密码： 重新输入新的 UNIX 密码： passwd：已成功更新密码</div><div>输入新的 UNIX 密码： 重新输入新的 UNIX 密码： passwd：已成功更新密码</div><div>输入新的 UNIX 密码： 重新输入新的 UNIX 密码： passwd：已成功更新密码</div><div>输入新的 UNIX 密码： 重新输入新的 UNIX 密码： passwd：已成功更新密码</div><div>输入新的 UNIX 密码： 重新输入新的 UNIX 密码： passwd：已成功更新密码</div><div>输入新的 UNIX 密码： 重新输入新的 UNIX 密码： passwd：已成功更新密码</div><div>输入新的 UNIX 密码： 重新输入新的 UNIX 密码： passwd：已成功更新密码</div><div>输入新的 UNIX 密码： 重新输入新的 UNIX 密码： passwd：已成功更新密码</div><div>输入新的 UNIX 密码： 重新输入新的 UNIX 密码： passwd：已成功更新密码</div><div><br></div><div>注销一下，尝试登录~</div><div>可以登录，OK！</div><div>然后再回到本来的用户,long1lfw,查看group组</div><div>long1lfw@ubuntu:~/桌面$ sudo cat -n /etc/group</div><div>&nbsp; &nbsp; &nbsp;1<span style="white-space:pre;"  > </span>root:x:0:</div><div>&nbsp; &nbsp; &nbsp;2<span style="white-space:pre;"  > </span>daemon:x:1:</div><div>&nbsp; &nbsp; &nbsp;3<span style="white-space:pre;"  > </span>bin:x:2:</div><div>&nbsp; &nbsp; &nbsp;4<span style="white-space:pre;"  > </span>sys:x:3:</div><div>&nbsp; &nbsp; &nbsp;5<span style="white-space:pre;"  > </span>adm:x:4:long1lfw</div><div>&nbsp; &nbsp; &nbsp;6<span style="white-space:pre;"  > </span>tty:x:5:</div><div>&nbsp; &nbsp; &nbsp;7<span style="white-space:pre;"  > </span>disk:x:6:</div><div>&nbsp; &nbsp; &nbsp;8<span style="white-space:pre;"  > </span>lp:x:7:</div><div>&nbsp; &nbsp; &nbsp;9<span style="white-space:pre;"  > </span>mail:x:8:</div><div>&nbsp; &nbsp; 10<span style="white-space:pre;"  > </span>news:x:9:</div><div>&nbsp; &nbsp; 11<span style="white-space:pre;"  > </span>uucp:x:10:</div><div>&nbsp; &nbsp; 12<span style="white-space:pre;"  > </span>man:x:12:</div><div>&nbsp; &nbsp; 13<span style="white-space:pre;"  > </span>proxy:x:13:</div><div>&nbsp; &nbsp; 14<span style="white-space:pre;"  > </span>kmem:x:15:</div><div>&nbsp; &nbsp; 15<span style="white-space:pre;"  > </span>dialout:x:20:long1lfw</div><div>&nbsp; &nbsp; 16<span style="white-space:pre;"  > </span>fax:x:21:</div><div>&nbsp; &nbsp; 17<span style="white-space:pre;"  > </span>voice:x:22:</div><div>&nbsp; &nbsp; 18<span style="white-space:pre;"  > </span>cdrom:x:24:long1lfw</div><div>&nbsp; &nbsp; 19<span style="white-space:pre;"  > </span>floppy:x:25:</div><div>&nbsp; &nbsp; 20<span style="white-space:pre;"  > </span>tape:x:26:</div><div>&nbsp; &nbsp; 21<span style="white-space:pre;"  > </span>sudo:x:27:</div><div>&nbsp; &nbsp; 22<span style="white-space:pre;"  > </span>audio:x:29:pulse</div><div>&nbsp; &nbsp; 23<span style="white-space:pre;"  > </span>dip:x:30:</div><div>&nbsp; &nbsp; 24<span style="white-space:pre;"  > </span>www-data:x:33:</div><div>&nbsp; &nbsp; 25<span style="white-space:pre;"  > </span>backup:x:34:</div><div>&nbsp; &nbsp; 26<span style="white-space:pre;"  > </span>operator:x:37:</div><div>&nbsp; &nbsp; 27<span style="white-space:pre;"  > </span>list:x:38:</div><div>&nbsp; &nbsp; 28<span style="white-space:pre;"  > </span>irc:x:39:</div><div>&nbsp; &nbsp; 29<span style="white-space:pre;"  > </span>src:x:40:</div><div>&nbsp; &nbsp; 30<span style="white-space:pre;"  > </span>gnats:x:41:</div><div>&nbsp; &nbsp; 31<span style="white-space:pre;"  > </span>shadow:x:42:</div><div>&nbsp; &nbsp; 32<span style="white-space:pre;"  > </span>utmp:x:43:</div><div>&nbsp; &nbsp; 33<span style="white-space:pre;"  > </span>video:x:44:</div><div>&nbsp; &nbsp; 34<span style="white-space:pre;"  > </span>sasl:x:45:</div><div>&nbsp; &nbsp; 35<span style="white-space:pre;"  > </span>plugdev:x:46:long1lfw</div><div>&nbsp; &nbsp; 36<span style="white-space:pre;"  > </span>staff:x:50:</div><div>&nbsp; &nbsp; 37<span style="white-space:pre;"  > </span>games:x:60:</div><div>&nbsp; &nbsp; 38<span style="white-space:pre;"  > </span>users:x:100:</div><div>&nbsp; &nbsp; 39<span style="white-space:pre;"  > </span>nogroup:x:65534:</div><div>&nbsp; &nbsp; 40<span style="white-space:pre;"  > </span>libuuid:x:101:</div><div>&nbsp; &nbsp; 41<span style="white-space:pre;"  > </span>crontab:x:102:</div><div>&nbsp; &nbsp; 42<span style="white-space:pre;"  > </span>syslog:x:103:</div><div>&nbsp; &nbsp; 43<span style="white-space:pre;"  > </span>fuse:x:104:</div><div>&nbsp; &nbsp; 44<span style="white-space:pre;"  > </span>messagebus:x:105:</div><div>&nbsp; &nbsp; 45<span style="white-space:pre;"  > </span>mlocate:x:106:</div><div>&nbsp; &nbsp; 46<span style="white-space:pre;"  > </span>ssh:x:107:</div><div>&nbsp; &nbsp; 47<span style="white-space:pre;"  > </span>avahi-autoipd:x:108:</div><div>&nbsp; &nbsp; 48<span style="white-space:pre;"  > </span>avahi:x:109:</div><div>&nbsp; &nbsp; 49<span style="white-space:pre;"  > </span>netdev:x:110:</div><div>&nbsp; &nbsp; 50<span style="white-space:pre;"  > </span>lpadmin:x:111:long1lfw</div><div>&nbsp; &nbsp; 51<span style="white-space:pre;"  > </span>ssl-cert:x:112:</div><div>&nbsp; &nbsp; 52<span style="white-space:pre;"  > </span>couchdb:x:113:</div><div>&nbsp; &nbsp; 53<span style="white-space:pre;"  > </span>pulse:x:114:</div><div>&nbsp; &nbsp; 54<span style="white-space:pre;"  > </span>pulse-access:x:115:</div><div>&nbsp; &nbsp; 55<span style="white-space:pre;"  > </span>utempter:x:116:</div><div>&nbsp; &nbsp; 56<span style="white-space:pre;"  > </span>rtkit:x:117:</div><div>&nbsp; &nbsp; 57<span style="white-space:pre;"  > </span>saned:x:118:</div><div>&nbsp; &nbsp; 58<span style="white-space:pre;"  > </span>admin:x:119:long1lfw</div><div>&nbsp; &nbsp; 59<span style="white-space:pre;"  > </span>gdm:x:120:</div><div>&nbsp; &nbsp; 60<span style="white-space:pre;"  > </span>nopasswdlogin:x:121:</div><div>&nbsp; &nbsp; 61<span style="white-space:pre;"  > </span>long1lfw:x:1000:</div><div>&nbsp; &nbsp; 62<span style="white-space:pre;"  > </span>sambashare:x:122:long1lfw</div><div>&nbsp; &nbsp; 63<span style="white-space:pre;"  > </span>jetty:x:123:</div><div>&nbsp; &nbsp; 64<span style="white-space:pre;"  > </span>haldaemon:x:124:</div><div>&nbsp; &nbsp; 65<span style="white-space:pre;"  > </span>class1:x:1001:</div><div>&nbsp; &nbsp; 66<span style="white-space:pre;"  > </span>stu01:x:1002:</div><div>&nbsp; &nbsp; 67<span style="white-space:pre;"  > </span>stu02:x:1003:</div><div>&nbsp; &nbsp; 68<span style="white-space:pre;"  > </span>stu03:x:1004:</div><div>&nbsp; &nbsp; 69<span style="white-space:pre;"  > </span>stu04:x:1005:</div><div>&nbsp; &nbsp; 70<span style="white-space:pre;"  > </span>stu05:x:1006:</div><div>&nbsp; &nbsp; 71<span style="white-space:pre;"  > </span>stu06:x:1007:</div><div>&nbsp; &nbsp; 72<span style="white-space:pre;"  > </span>stu07:x:1008:</div><div>&nbsp; &nbsp; 73<span style="white-space:pre;"  > </span>stu08:x:1009:</div><div>&nbsp; &nbsp; 74<span style="white-space:pre;"  > </span>stu09:x:1010:</div><div>&nbsp; &nbsp; 75<span style="white-space:pre;"  > </span>stu10:x:1011:</div><div>&nbsp; &nbsp; 76<span style="white-space:pre;"  > </span>stu11:x:1012:</div><div>&nbsp; &nbsp; 77<span style="white-space:pre;"  > </span>stu12:x:1013:</div><div>&nbsp; &nbsp; 78<span style="white-space:pre;"  > </span>stu13:x:1014:</div><div>&nbsp; &nbsp; 79<span style="white-space:pre;"  > </span>stu14:x:1015:</div><div>&nbsp; &nbsp; 80<span style="white-space:pre;"  > </span>stu15:x:1016:</div><div>&nbsp; &nbsp; 81<span style="white-space:pre;"  > </span>stu16:x:1017:</div><div>&nbsp; &nbsp; 82<span style="white-space:pre;"  > </span>stu17:x:1018:</div><div>&nbsp; &nbsp; 83<span style="white-space:pre;"  > </span>stu18:x:1019:</div><div>&nbsp; &nbsp; 84<span style="white-space:pre;"  > </span>stu19:x:1020:</div><div>&nbsp; &nbsp; 85<span style="white-space:pre;"  > </span>stu20:x:1021:</div><div>&nbsp; &nbsp; 86<span style="white-space:pre;"  > </span>stu21:x:1022:</div><div>&nbsp; &nbsp; 87<span style="white-space:pre;"  > </span>stu22:x:1023:</div><div>&nbsp; &nbsp; 88<span style="white-space:pre;"  > </span>stu23:x:1024:</div><div>&nbsp; &nbsp; 89<span style="white-space:pre;"  > </span>stu24:x:1025:</div><div>&nbsp; &nbsp; 90<span style="white-space:pre;"  > </span>stu25:x:1026:</div><div>&nbsp; &nbsp; 91<span style="white-space:pre;"  > </span>stu26:x:1027:</div><div>&nbsp; &nbsp; 92<span style="white-space:pre;"  > </span>stu27:x:1028:</div><div>&nbsp; &nbsp; 93<span style="white-space:pre;"  > </span>stu28:x:1029:</div><div>&nbsp; &nbsp; 94<span style="white-space:pre;"  > </span>stu29:x:1030:</div><div>&nbsp; &nbsp; 95<span style="white-space:pre;"  > </span>stu30:x:1031:</div><div>从65到95就是新添的，再运行sudo ./delclass1.sh</div><div>long1lfw@ubuntu:~/桌面$ sudo ./delclass1.sh</div><div>long1lfw@ubuntu:~/桌面$ sudo cat -n /etc/group</div><div>&nbsp; &nbsp; &nbsp;1<span style="white-space:pre;"  > </span>root:x:0:</div><div>&nbsp; &nbsp; &nbsp;2<span style="white-space:pre;"  > </span>daemon:x:1:</div><div>&nbsp; &nbsp; &nbsp;3<span style="white-space:pre;"  > </span>bin:x:2:</div><div>&nbsp; &nbsp; &nbsp;4<span style="white-space:pre;"  > </span>sys:x:3:</div><div>&nbsp; &nbsp; &nbsp;5<span style="white-space:pre;"  > </span>adm:x:4:long1lfw</div><div>&nbsp; &nbsp; &nbsp;6<span style="white-space:pre;"  > </span>tty:x:5:</div><div>&nbsp; &nbsp; &nbsp;7<span style="white-space:pre;"  > </span>disk:x:6:</div><div>&nbsp; &nbsp; &nbsp;8<span style="white-space:pre;"  > </span>lp:x:7:</div><div>&nbsp; &nbsp; &nbsp;9<span style="white-space:pre;"  > </span>mail:x:8:</div><div>&nbsp; &nbsp; 10<span style="white-space:pre;"  > </span>news:x:9:</div><div>&nbsp; &nbsp; 11<span style="white-space:pre;"  > </span>uucp:x:10:</div><div>&nbsp; &nbsp; 12<span style="white-space:pre;"  > </span>man:x:12:</div><div>&nbsp; &nbsp; 13<span style="white-space:pre;"  > </span>proxy:x:13:</div><div>&nbsp; &nbsp; 14<span style="white-space:pre;"  > </span>kmem:x:15:</div><div>&nbsp; &nbsp; 15<span style="white-space:pre;"  > </span>dialout:x:20:long1lfw</div><div>&nbsp; &nbsp; 16<span style="white-space:pre;"  > </span>fax:x:21:</div><div>&nbsp; &nbsp; 17<span style="white-space:pre;"  > </span>voice:x:22:</div><div>&nbsp; &nbsp; 18<span style="white-space:pre;"  > </span>cdrom:x:24:long1lfw</div><div>&nbsp; &nbsp; 19<span style="white-space:pre;"  > </span>floppy:x:25:</div><div>&nbsp; &nbsp; 20<span style="white-space:pre;"  > </span>tape:x:26:</div><div>&nbsp; &nbsp; 21<span style="white-space:pre;"  > </span>sudo:x:27:</div><div>&nbsp; &nbsp; 22<span style="white-space:pre;"  > </span>audio:x:29:pulse</div><div>&nbsp; &nbsp; 23<span style="white-space:pre;"  > </span>dip:x:30:</div><div>&nbsp; &nbsp; 24<span style="white-space:pre;"  > </span>www-data:x:33:</div><div>&nbsp; &nbsp; 25<span style="white-space:pre;"  > </span>backup:x:34:</div><div>&nbsp; &nbsp; 26<span style="white-space:pre;"  > </span>operator:x:37:</div><div>&nbsp; &nbsp; 27<span style="white-space:pre;"  > </span>list:x:38:</div><div>&nbsp; &nbsp; 28<span style="white-space:pre;"  > </span>irc:x:39:</div><div>&nbsp; &nbsp; 29<span style="white-space:pre;"  > </span>src:x:40:</div><div>&nbsp; &nbsp; 30<span style="white-space:pre;"  > </span>gnats:x:41:</div><div>&nbsp; &nbsp; 31<span style="white-space:pre;"  > </span>shadow:x:42:</div><div>&nbsp; &nbsp; 32<span style="white-space:pre;"  > </span>utmp:x:43:</div><div>&nbsp; &nbsp; 33<span style="white-space:pre;"  > </span>video:x:44:</div><div>&nbsp; &nbsp; 34<span style="white-space:pre;"  > </span>sasl:x:45:</div><div>&nbsp; &nbsp; 35<span style="white-space:pre;"  > </span>plugdev:x:46:long1lfw</div><div>&nbsp; &nbsp; 36<span style="white-space:pre;"  > </span>staff:x:50:</div><div>&nbsp; &nbsp; 37<span style="white-space:pre;"  > </span>games:x:60:</div><div>&nbsp; &nbsp; 38<span style="white-space:pre;"  > </span>users:x:100:</div><div>&nbsp; &nbsp; 39<span style="white-space:pre;"  > </span>nogroup:x:65534:</div><div>&nbsp; &nbsp; 40<span style="white-space:pre;"  > </span>libuuid:x:101:</div><div>&nbsp; &nbsp; 41<span style="white-space:pre;"  > </span>crontab:x:102:</div><div>&nbsp; &nbsp; 42<span style="white-space:pre;"  > </span>syslog:x:103:</div><div>&nbsp; &nbsp; 43<span style="white-space:pre;"  > </span>fuse:x:104:</div><div>&nbsp; &nbsp; 44<span style="white-space:pre;"  > </span>messagebus:x:105:</div><div>&nbsp; &nbsp; 45<span style="white-space:pre;"  > </span>mlocate:x:106:</div><div>&nbsp; &nbsp; 46<span style="white-space:pre;"  > </span>ssh:x:107:</div><div>&nbsp; &nbsp; 47<span style="white-space:pre;"  > </span>avahi-autoipd:x:108:</div><div>&nbsp; &nbsp; 48<span style="white-space:pre;"  > </span>avahi:x:109:</div><div>&nbsp; &nbsp; 49<span style="white-space:pre;"  > </span>netdev:x:110:</div><div>&nbsp; &nbsp; 50<span style="white-space:pre;"  > </span>lpadmin:x:111:long1lfw</div><div>&nbsp; &nbsp; 51<span style="white-space:pre;"  > </span>ssl-cert:x:112:</div><div>&nbsp; &nbsp; 52<span style="white-space:pre;"  > </span>couchdb:x:113:</div><div>&nbsp; &nbsp; 53<span style="white-space:pre;"  > </span>pulse:x:114:</div><div>&nbsp; &nbsp; 54<span style="white-space:pre;"  > </span>pulse-access:x:115:</div><div>&nbsp; &nbsp; 55<span style="white-space:pre;"  > </span>utempter:x:116:</div><div>&nbsp; &nbsp; 56<span style="white-space:pre;"  > </span>rtkit:x:117:</div><div>&nbsp; &nbsp; 57<span style="white-space:pre;"  > </span>saned:x:118:</div><div>&nbsp; &nbsp; 58<span style="white-space:pre;"  > </span>admin:x:119:long1lfw</div><div>&nbsp; &nbsp; 59<span style="white-space:pre;"  > </span>gdm:x:120:</div><div>&nbsp; &nbsp; 60<span style="white-space:pre;"  > </span>nopasswdlogin:x:121:</div><div>&nbsp; &nbsp; 61<span style="white-space:pre;"  > </span>long1lfw:x:1000:</div><div>&nbsp; &nbsp; 62<span style="white-space:pre;"  > </span>sambashare:x:122:long1lfw</div><div>&nbsp; &nbsp; 63<span style="white-space:pre;"  > </span>jetty:x:123:</div><div>&nbsp; &nbsp; 64<span style="white-space:pre;"  > </span>haldaemon:x:124:</div><div><br></div><div>就但删除了，目录也用rm -rf强制删除了(r表示目录， f表示强制)</div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >(long1&nbsp;vs&nbsp;longpo&nbsp;转载请注明出处：</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px;"  ><a style="color: rgb(80, 80, 80); text-decoration: none; " href="http://blog.163.com/lfw2565295@126"  ><span style="line-height: 25px; color: rgb(0, 0, 255); text-decoration: underline; font-size: 10.5pt; font-family: 宋体;"  >http://blog.163.com/lfw2565295@126</span></a></span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >)</span></div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  ><br></span></div><wbr></div>]]></description>
	    <author><![CDATA[long1]]></author>
	    <comments>http://blog.163.com/lfw2565295@126/blog/static/122005162012436197458</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/lfw2565295@126/blog/static/122005162012436197458</guid>
    <pubDate>Thu, 3 May 2012 18:19:07 +0800</pubDate>
    <dcterms:modified>2012-05-03T18:23:31+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[shell 函数]]></title>	
    <link>http://blog.163.com/lfw2565295@126/blog/static/122005162012411275128</link>
    <description><![CDATA[<div><div>函数</div><div><br></div><div>type命令告诉正在执行的命令的来源是别名，函数，或外部命令，如：</div><div>long1lfw@ubuntu:~$ type ls</div><div>ls 已被别名为“ls --color=auto”</div><div>long1lfw@ubuntu:~$ type echo</div><div>echo 是一个 shell 内部命令</div><div>long1lfw@ubuntu:~$ type cat</div><div>cat 是 /bin/cat</div><div><br></div><div>ls来自alias,echo是shell内部命令,cat则是外部命令</div><div><br></div><div>函数需要先定义，后使用，用exit退出脚本，用return返回到调用的地方</div><div>return语句返回函数执行最后一条命令的退出状态</div><div>declare -f或-F可以看字典序的函数定义</div><div><br></div><div>定义函数可以用function funcname() { shell comands}</div><div>或 funcname() { shell commands}</div><div>删除可以用unset -f funcname，-f表示unset删除的是函数</div><div><br></div><div>写一个user_login.sh:</div><div>#! /bin/bash</div><div>function user_login()</div><div>{</div><div>&nbsp; if who | grep $1 &gt;/dev/null</div><div>&nbsp; then echo "User $1 is on."</div><div>&nbsp; else echo "User $1 is off."</div><div>&nbsp; fi</div><div>}</div><div>long1lfw@ubuntu:~/桌面$ source user_login.sh</div><div>long1lfw@ubuntu:~/桌面$ user_login long1lfw</div><div>User long1lfw is on.</div><div>long1lfw@ubuntu:~/桌面$ user_login longpo</div><div>User longpo is off.</div><div>通过source命令将函数从文件读入，函数就如同命令一样变得可调用。然后传入参数$1表示第一个参数，判断用户是否在线。</div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >(long1&nbsp;vs&nbsp;longpo&nbsp;转载请注明出处：</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px;"  ><a style="color: rgb(80, 80, 80); text-decoration: none; " href="http://blog.163.com/lfw2565295@126"  ><span style="line-height: 25px; color: rgb(0, 0, 255); text-decoration: underline; font-size: 10.5pt; font-family: 宋体;"  >http://blog.163.com/lfw2565295@126</span></a></span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >)</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 'Times New Roman';"  >&nbsp;</span></div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 'Times New Roman';"  ><br></span></div><div>看函数怎么返回值的例子：</div><div>add.sh:</div><div>#! /bin/bash</div><div>add()</div><div>{</div><div>&nbsp; let "sum=$1+$2"</div><div>&nbsp; return $sum</div><div>}</div><div>long1lfw@ubuntu:~/桌面$ source add.sh</div><div>long1lfw@ubuntu:~/桌面$ add 3 4</div><div>long1lfw@ubuntu:~/桌面$ echo $?</div><div>7</div><div><br></div><div>$? 中保存的是上一条命令的返回值，正是如此，执行完add 3 4后，可以使用echo $?来获取执行的返回结果</div><div><br></div><div>if/else语句，结果：</div><div>if condition</div><div>then</div><div>&nbsp; &nbsp; statements</div><div>[elif condition</div><div>then</div><div>&nbsp; &nbsp; statements...]</div><div>[else</div><div>&nbsp; &nbsp; statement ]</div><div>fi</div><div><br></div><div>退出用0表示成功，非0表示失败，$? 结果如果是0，表示正常退出，否则异常，如：</div><div>long1lfw@ubuntu:~/桌面$ cat /etc/shadow</div><div>cat: /etc/shadow: 权限不够</div><div>long1lfw@ubuntu:~/桌面$ echo $?</div><div>1</div><div><br></div><div>if语句唯一可以测试的内容是退出状态，不能用于检测表达式的值。但通过test命令可以连用</div><div>if test 2 -gt 3</div><div>then</div><div>&nbsp; &nbsp; ...</div><div>fi</div><div>等同于</div><div>if [ 2 -gt 3 ] #[,]前必须有空格</div><div>then</div><div>&nbsp; &nbsp; ...</div><div>fi</div><div><br></div><div><br></div><div>看个例子：</div><div>add.sh:</div><div>#! /bin/bash</div><div><br></div><div>add()</div><div>{</div><div>&nbsp; if [ $1 -gt $2 ]</div><div>&nbsp; then</div><div>&nbsp; &nbsp; let "sum=$1+$2"</div><div>&nbsp; else&nbsp;</div><div>&nbsp; &nbsp; let &nbsp;"sum=0"</div><div>&nbsp; fi</div><div>&nbsp; return $sum</div><div>}</div><div><br></div><div>long1lfw@ubuntu:~/桌面$ vim add.sh</div><div>long1lfw@ubuntu:~/桌面$ source add.sh</div><div>long1lfw@ubuntu:~/桌面$ add 4 5</div><div>long1lfw@ubuntu:~/桌面$ echo $?</div><div>0</div><div>long1lfw@ubuntu:~/桌面$ add 5 4</div><div>long1lfw@ubuntu:~/桌面$ echo $?</div><div>9</div><div><br></div><div>当第一个参数大于第二个参数执行相加，数字型的比较有： -eg等于 -ne不等与 -lt小于 -le小于等于 -gt大于 -ge大于等于</div><div>字符型的比较有：-z长度为0 -n长度非0 =相等 ！=不等&nbsp;</div><div>文件测试有：-b存在并且是块文件 -c存在且是字符文件 -d路径存在且是一个目录 -e指定的文件或目录存在 -f存在且是正规文件 -g文件或目录存在且设置了SGID位 -h存在且是符号链接文件 -s文件存在且文件大小大于0 -w可写 -r可读 -x可执行</div><div>符合表达式： !假为真 -a同时为真 -o有一个为真</div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >(long1&nbsp;vs&nbsp;longpo&nbsp;转载请注明出处：</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px;"  ><a style="color: rgb(80, 80, 80); text-decoration: none; " href="http://blog.163.com/lfw2565295@126"  ><span style="line-height: 25px; color: rgb(0, 0, 255); text-decoration: underline; font-size: 10.5pt; font-family: 宋体;"  >http://blog.163.com/lfw2565295@126</span></a></span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >)</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 'Times New Roman';"  >&nbsp;</span></div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 'Times New Roman';"  ><br></span></div><wbr></div>]]></description>
	    <author><![CDATA[long1]]></author>
	    <comments>http://blog.163.com/lfw2565295@126/blog/static/122005162012411275128</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/lfw2565295@126/blog/static/122005162012411275128</guid>
    <pubDate>Tue, 1 May 2012 13:27:51 +0800</pubDate>
    <dcterms:modified>2012-05-01T13:27:51+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[shell的变量]]></title>	
    <link>http://blog.163.com/lfw2565295@126/blog/static/12200516201232772757502</link>
    <description><![CDATA[<div><div><b><font color="#0000ff"  >shell是一种动态类型语言(不使用显式数据声明)和弱类型语言(变量类型操作根据需求而不同)。shell变成中的变量是不分类型的(都是字符串类型)，但是依赖于具体的上下文，shell编程也允许比较操作和整数操作。</font></b></div><div>看下面例子：</div><div>variable.sh:</div><div>#!/bin/bash</div><div><br></div><div>a=2334 #整型</div><div>let "a+=1"</div><div>echo "a=$a" #a=2335</div><div>echo #还是整型</div><div><br></div><div>b=${a/23/BB} #将"23"替换成"BB",这将把b从整型变为字符串</div><div>echo "b=$b" &nbsp;#b=BB35</div><div>declare -i b #即使使用declare命令也不会对此有任何帮助</div><div>echo "b=$b" &nbsp;#b=BB35</div><div><br></div><div>let "b += 1" #BB35 + 1 =</div><div>echo "b=$b" &nbsp;#b = 1</div><div>echo</div><div><br></div><div>c=BB34</div><div>echo "c=$c" &nbsp;#c=BB34</div><div>d=${c/BB/23} #降"BB"替换成"23",这使得变量$d变为一个整型</div><div><br></div><div>echo "d=$d" &nbsp;#d = 2334</div><div>let "d += 1" #2334 + 1=</div><div>echo "d=$d" &nbsp;#d=2335</div><div>echo</div><div><br></div><div>#null 变量会如何</div><div>e=""</div><div>echo "e=$e" &nbsp;#e =</div><div>let "e += 1" #算术操作允许一个null变量？</div><div>echo "e=$e" &nbsp;#e=1</div><div>echo &nbsp; &nbsp; &nbsp; &nbsp; #null变量将被转换成一个整型变量</div><div><br></div><div>#如果没有声明变量会怎么样</div><div>echo "f=$f" &nbsp;#f=</div><div>let "f += 1" #算术操作能通过吗？</div><div>echo "f=$f" &nbsp;#f=1</div><div>echo &nbsp; &nbsp; &nbsp; &nbsp; #未声明的变量将转换成一个整型变量</div><div><br></div><div>#所以bash shell中的变量都是不去分类型的</div><div>exit 0</div><div><br></div><div>运行：</div><div>long1lfw@ubuntu:~/桌面$ vim variable.sh</div><div>long1lfw@ubuntu:~/桌面$ chmod +x variable.sh</div><div>long1lfw@ubuntu:~/桌面$ ./variable.sh</div><div>a=2335</div><div><br></div><div>b=BB35</div><div>b=BB35</div><div>b=1</div><div><br></div><div>c=BB34</div><div>d=2334</div><div>d=2335</div><div><br></div><div>e=</div><div>e=1</div><div><br></div><div>f=</div><div>f=1</div><div><br></div><div>结果跟注释的一样</div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >(long1&nbsp;vs&nbsp;longpo&nbsp;转载请注明出处：</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px;"  ><a style="color: rgb(80, 80, 80); text-decoration: none; " href="http://blog.163.com/lfw2565295@126"  ><span style="line-height: 25px; color: rgb(0, 0, 255); text-decoration: underline; font-size: 10.5pt; font-family: 宋体;"  >http://blog.163.com/lfw2565295@126</span></a></span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >)</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 'Times New Roman';"  >&nbsp;</span></div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 'Times New Roman';"  ><br></span></div><div>shell里有三种变量：用户变量，位置变量和环境变量。</div><div><b><font color="#0000ff"  >1.用户变量</font></b></div><div>有分全局和局部，默认是全局，局部的话需要使用local限定词。</div><div>定义为 varname=value，等号两边不能有空格。 变量值多于一个单词，必须用引号引起来。要在命令中引用，在其名字前加符合$</div><div>例如：</div><div>str=how are you? &nbsp; &nbsp;#错误，没加引号</div><div>str = "how are you?"#错误，等号左右不能有空格</div><div>str="how are you?" &nbsp;#正确</div><div>echo str &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#错误，要引用str的值，需要用$</div><div>echo $str &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #正确</div><div>unset varname 可以删除变量，但一般不这样使用</div><div>默认变量返回空字符串</div><div><br></div><div>要打出特殊字符需要转义，使用\$, \~等，如：</div><div>long1lfw@ubuntu:~/桌面$ echo $you</div><div>me</div><div>long1lfw@ubuntu:~/桌面$ echo \$you</div><div>$you</div><div><br></div><div>弱引用""和强引用'', 强引用让引用内的变量失效，弱的让部分失效，例子：</div><div>long1lfw@ubuntu:~/桌面$ vname=lfw</div><div>long1lfw@ubuntu:~/桌面$ echo "I am $vname"</div><div>I am lfw</div><div>long1lfw@ubuntu:~/桌面$ echo 'I am $vname'</div><div>I am $vname</div><div><br></div><div>正式的表示方式为${vname}, 上面例子，如果要输出lfw_,不能用echo $vname_,只能用${vname}_,因为变量的命名方式和c,java类似，把vname_当成变量了</div><div><br></div><div>操作字符串有替换运算符，模式匹配运算符</div><div>模式匹配运算符的一个应用，如${varname//pattern/string}替换任意的pattern为string(如果一个/就替换第一个)，应用于查看环境变量 echo -e ${PATH//:/'\n'}</div><div>/usr/local/sbin</div><div>/usr/local/bin</div><div>/usr/sbin</div><div>/usr/bin</div><div>/sbin</div><div>/bin</div><div>/usr/games</div><div><br></div><div>-e允许将echo的\n解释为一个LINEFEED</div><div>效果同等与sed命令： long1lfw@ubuntu:~/桌面$ echo $PATH | sed 's/:/\n/g'</div><div><br></div><div>使用`command` (`为1左边的键)命令替换，允许使用命令的标准输出</div><div>long1lfw@ubuntu:~/桌面$ echo `pwd`</div><div>/home/long1lfw/桌面</div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >(long1&nbsp;vs&nbsp;longpo&nbsp;转载请注明出处：</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px;"  ><a style="color: rgb(80, 80, 80); text-decoration: none; " href="http://blog.163.com/lfw2565295@126"  ><span style="line-height: 25px; color: rgb(0, 0, 255); text-decoration: underline; font-size: 10.5pt; font-family: 宋体;"  >http://blog.163.com/lfw2565295@126</span></a></span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >)</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 'Times New Roman';"  >&nbsp;</span></div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 'Times New Roman';"  ><br></span></div><div><b><font color="#0000ff"  >2.位置变量</font></b></div><div>$# 输出变量的个数</div><div>$? 输出上条命令的结束值</div><div>$0 输出命令的名字</div><div>$* 输出命令的所有参数</div><div>$1 $2 $9 ${10} 输出1 2 9 10的参数</div><div>例子：</div><div>long1lfw@ubuntu:~/桌面$ vim process.sh</div><div>long1lfw@ubuntu:~/桌面$ chmod +x process.sh</div><div>long1lfw@ubuntu:~/桌面$ ./process.sh a b</div><div>the script name is ./process.sh</div><div>$1=a; $2=b</div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >(long1&nbsp;vs&nbsp;longpo&nbsp;转载请注明出处：</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px;"  ><a style="color: rgb(80, 80, 80); text-decoration: none; " href="http://blog.163.com/lfw2565295@126"  ><span style="line-height: 25px; color: rgb(0, 0, 255); text-decoration: underline; font-size: 10.5pt; font-family: 宋体;"  >http://blog.163.com/lfw2565295@126</span></a></span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >)</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 'Times New Roman';"  >&nbsp;</span></div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 'Times New Roman';"  ><br></span></div><div><b><font color="#0000ff"  >3.环境变量</font></b></div><div>常见的环境变量有：PATH HOME HISTFILE IFS LOGNAME TERM等</div><div>可以用echo查看，如：</div><div>long1lfw@ubuntu:~/桌面$ echo $LOGNAME</div><div>long1lfw</div><div>当需要保存修改的环境变量时，我们使用export命令将变量修改写进启动文件里。对于不同的启动shell，启动文件不同</div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >(long1&nbsp;vs&nbsp;longpo&nbsp;转载请注明出处：</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px;"  ><a style="color: rgb(80, 80, 80); text-decoration: none; " href="http://blog.163.com/lfw2565295@126"  ><span style="line-height: 25px; color: rgb(0, 0, 255); text-decoration: underline; font-size: 10.5pt; font-family: 宋体;"  >http://blog.163.com/lfw2565295@126</span></a></span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >)</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 'Times New Roman';"  >&nbsp;</span></div><wbr></div>]]></description>
	    <author><![CDATA[long1]]></author>
	    <comments>http://blog.163.com/lfw2565295@126/blog/static/12200516201232772757502</comments>
    <slash:comments>1</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/lfw2565295@126/blog/static/12200516201232772757502</guid>
    <pubDate>Fri, 27 Apr 2012 19:27:57 +0800</pubDate>
    <dcterms:modified>2012-04-27T19:27:57+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[shell编程基础]]></title>	
    <link>http://blog.163.com/lfw2565295@126/blog/static/12200516201232613644941</link>
    <description><![CDATA[<div><div><b><font color="#0000ff"  >1.shell脚本的参数</font></b></div><div><br></div><div>long1lfw@ubuntu:~$ testfunc()</div><div>&gt; {</div><div>&gt; echo "$# parameters";</div><div>&gt; echo "$@";</div><div>&gt; }</div><div>其实$#表示传入参数个数，$@表示所有参数的内容,测试：</div><div>long1lfw@ubuntu:~$ testfunc</div><div>0 parameters</div><div><br></div><div>long1lfw@ubuntu:~$ testfunc a b c</div><div>3 parameters</div><div>a b c</div><div>long1lfw@ubuntu:~$ testfunc a " b c "</div><div>2 parameters</div><div>a &nbsp;b c&nbsp;</div><div><br></div><div>用vim建立一个文本写shell</div><div>#! /bin/bash</div><div>echo "$# parameters"</div><div>echo "$@";</div><div><br></div><div>注意，首行表示使用哪种shell运行，之后的 "#" 表示注释，类似C++的 "//"</div><div>写完后增加个权限，原来的权限是：</div><div>long1lfw@ubuntu:~/桌面$ ls -l testfunc.sh</div><div>-rw-r--r-- 1 long1lfw long1lfw 45 2012-04-26 12:30 testfunc.sh</div><div><b><font color="#0000ff"  >通过chmod +x testfunc.sh增加权限</font></b></div><div>long1lfw@ubuntu:~/桌面$ chmod +x testfunc.sh</div><div>long1lfw@ubuntu:~/桌面$ ls -l testfunc.sh</div><div>-rwxr-xr-x 1 long1lfw long1lfw 45 2012-04-26 12:30 testfunc.sh</div><div>最后运行，类似g++编译后的运行：</div><div>long1lfw@ubuntu:~/桌面$ ./testfunc.sh a "b c"</div><div>2 parameters</div><div>a b c</div><div><br></div><div>用户的#HOME目录为：</div><div>long1lfw@ubuntu:~/桌面$ echo $HOME</div><div>/home/long1lfw</div><div>就像命令前的~/桌面一样，可以用~来表示$HOME</div><div><br></div><div>mkdir可以创建一个或多个目录，如：</div><div>long1lfw@ubuntu:~/桌面$ mkdir ma mb</div><div>创建了ma 和 mb两个文件夹，删除目录也可以用rm 只是要多加 -r:</div><div>long1lfw@ubuntu:~/桌面$ rm -r ma mb</div><div>或者使用rmdir，但文件夹必须为空</div><div><br></div><div>mv可以移动或重命名文件或目录，如把b.txt 改为 b.cpp:</div><div>long1lfw@ubuntu:~/桌面$ mv b.txt b.cpp</div><div>把a.cpp移动到bm文件夹：</div><div>long1lfw@ubuntu:~/桌面$ sudo mv a.cpp bm</div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >(long1&nbsp;vs&nbsp;longpo&nbsp;转载请注明出处：</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px;"  ><a style="color: rgb(80, 80, 80); text-decoration: none; " href="http://blog.163.com/lfw2565295@126"  ><span style="line-height: 25px; color: rgb(0, 0, 255); text-decoration: underline; font-size: 10.5pt; font-family: 宋体;"  >http://blog.163.com/lfw2565295@126</span></a></span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >)</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 'Times New Roman';"  >&nbsp;</span></div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 'Times New Roman';"  ><br></span></div><div><b><font color="#0000ff"  >2.I/O重定向</font></b></div><div>echo的行为(1)读取echo参数中的变量，将所有变量替换成值，变成字符串输出；(2)在输出的末尾追加换行符，退出程序</div><div>如：</div><div>long1lfw@ubuntu:~/桌面$ echo $PATH</div><div>/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games</div><div><br></div><div>cat的使用，运行cat命令，你输入什么，它就回复什么，用ctrl+D结束</div><div>或者查看某个文件： long1lfw@ubuntu:~/桌面$ cat bm/a.cpp</div><div>就会显示bm文件夹下a.cpp的内容到终端</div><div><br></div><div>"&gt;" "&lt;" "&gt;&gt;"几种重定向</div><div>long1lfw@ubuntu:~/桌面$ echo "$PATH" &gt; try</div><div>就把echo的结果输入到try文件里，但会覆盖try</div><div>long1lfw@ubuntu:~/桌面$ cat &lt; try &gt;try2</div><div>使用cat &lt; try输出try的内容，然后&gt; try2输入到try2中</div><div>long1lfw@ubuntu:~/桌面$ cat &lt; try &gt;&gt; try2</div><div>使用"&gt;&gt;" 就不是覆盖了，而是追加到未行</div><div><br></div><div>“|” 管道，类似"&lt;"和"&gt;"的组合，读出前者作为输入到后者,常与文本检索命令"grep"连用</div><div>比如读取try2前5行作为输入，给grep，让它查找"try"在哪里</div><div>long1lfw@ubuntu:~/桌面$ head -n5 try2 | grep "try"</div><div>或者 long1lfw@ubuntu:~/桌面$ cat try | cat</div><div><br></div><div>内核(kernel)通过文件描述符(file descriptor)来访问文件，文件描述符是非负整数，打开现存文件或新建文件时，内核会返回一个文件描述符。</div><div>（1）文件描述符表 （2）系统文件表 （3）内存索引节点表</div><div>习惯上标准输入的文件描述符是0，标准输出是1，标准错误是2</div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >(long1&nbsp;vs&nbsp;longpo&nbsp;转载请注明出处：</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px;"  ><a style="color: rgb(80, 80, 80); text-decoration: none; " href="http://blog.163.com/lfw2565295@126"  ><span style="line-height: 25px; color: rgb(0, 0, 255); text-decoration: underline; font-size: 10.5pt; font-family: 宋体;"  >http://blog.163.com/lfw2565295@126</span></a></span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >)</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 'Times New Roman';"  >&nbsp;</span></div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 'Times New Roman';"  ><br></span></div><div><b><font color="#0000ff"  >Linux/UNIX下存在一些特殊的文件。</font></b>例如/dev下的null和zero文件。 null文件相当与Linux系统的一个黑洞，它非常接近于一个只写文件。所有写入它的内容都会永远丢失。而如果想从它那读取内容，则什么也读不到。zero文件则可以读出一串二进制的0。 tty文件与当前的控制终端直接相连。</div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >(long1&nbsp;vs&nbsp;longpo&nbsp;转载请注明出处：</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px;"  ><a style="color: rgb(80, 80, 80); text-decoration: none; " href="http://blog.163.com/lfw2565295@126"  ><span style="line-height: 25px; color: rgb(0, 0, 255); text-decoration: underline; font-size: 10.5pt; font-family: 宋体;"  >http://blog.163.com/lfw2565295@126</span></a></span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >)</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 'Times New Roman';"  >&nbsp;</span></div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 'Times New Roman';"  ><br></span></div><wbr></div>]]></description>
	    <author><![CDATA[long1]]></author>
	    <comments>http://blog.163.com/lfw2565295@126/blog/static/12200516201232613644941</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/lfw2565295@126/blog/static/12200516201232613644941</guid>
    <pubDate>Thu, 26 Apr 2012 13:36:44 +0800</pubDate>
    <dcterms:modified>2012-04-26T13:36:44+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[Linux下的线程控制 (C语言实现)]]></title>	
    <link>http://blog.163.com/lfw2565295@126/blog/static/12200516201232293058547</link>
    <description><![CDATA[<div><div><font color="#0000ff"  ><b>Linux下的线程控制</b></font></div><div>线程(thread),现在很多系统支持多线程了。与进程相比，它是一种非常“节俭”的多任务操作方式，启动一个新进程必须分配给它独立的地址空间，建立众多的数据表来维护它的代码段，堆栈段和数据段，这是一种“昂贵“的多任务工作方式。而运行于一个进程中的多个线程，他们彼此之间使用相同的地址空间，共享大部分数据，启动一个线程所花费的空间远远小于启动一个进程所花费的空间，而且，线程间彼此切换所需的时间也远远小于进程间切换所需要的时间。进程开销是线程的30倍左右。</div><div><font color="#0000ff"  ><b>另外线程间通信很方便。</b></font>进程有独立的数据空间，要进行数据的传递只能通过数据传递，不仅费时，而且很不方便。线程因为在同一进程下共享数据空间，所以一个线程的数据可以直接为其它线程所用，快捷方便。但要注意变量为多个线程修改，也容易出错，需要同步机制。</div><div><b><font color="#0000ff"  >多线程也作为多任务，并发的工作方式：</font></b></div><div>1.提高应用程序响应。对于图形界面的程序，有些操作耗时很长，此时可以其它操作。&nbsp;</div><div>2.使多CPU系统更加有效。操作系统保证线程数小于CPU数时，不同线程运行于不同的CPU。&nbsp;</div><div>3.改善程序结构。一个即长又复杂的进程可以考虑分为多个线程，成为几个独立或半独立的运行部分，这样的程序利于理解和修改。</div><div><br></div><div>线程是程序执行流的最小单元，由线程ID，当前指令指针(PC),寄存器集合和堆栈组成。</div><div>线程是进程中的一个实体，被系统独立调度和分配的基本单元。线程也有就绪、阻塞和运行三种基本状态。</div><div>线程是程序中一个单一的顺序控制流程，单个程序中同时运行多个线程完成不同工作，成为多线程。</div><div>各线程共享进程资源和环境。</div><div><b><font color="#0000ff"  >Linux线程函数位于libpthread共享库中，编译时要加上 -lpthread 选项</font></b></div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >(long1&nbsp;vs&nbsp;longpo&nbsp;转载请注明出处：</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px;"  ><a style="color: rgb(80, 80, 80); text-decoration: none; " href="http://blog.163.com/lfw2565295@126"  ><span style="line-height: 25px; color: rgb(0, 0, 255); text-decoration: underline; font-size: 10.5pt; font-family: 宋体;"  >http://blog.163.com/lfw2565295@126</span></a></span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >)</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 'Times New Roman';"  >&nbsp;</span></div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 'Times New Roman';"  ><br></span></div><div>例子：</div><div>#include&lt;stdio.h&gt;</div><div>#include&lt;stdlib.h&gt;</div><div>#include&lt;pthread.h&gt;</div><div><br></div><div>pthread_t nt;</div><div><br></div><div>//打印对应的进程和线程id</div><div>void printid(const char *s){</div><div>&nbsp; &nbsp; pid_t p;</div><div>&nbsp; &nbsp; pthread_t t;</div><div>&nbsp; &nbsp; p=getpid();</div><div>&nbsp; &nbsp; t=pthread_self();</div><div>&nbsp; &nbsp; printf("%s pid is %u, tid is %u\n",s,(unsigned int)p,(unsigned int)t);</div><div>}</div><div><br></div><div>//线程执行函数</div><div>void* f(void *arg){ //c语言里,NULL是void*，在c++中NULL就是0</div><div>&nbsp; &nbsp; printid("new thread: ");</div><div>&nbsp; &nbsp; return ((void*)0);</div><div>}</div><div><br></div><div>//主函数</div><div>int main(int argc, char **argv){</div><div>&nbsp; &nbsp; int result;</div><div>&nbsp; &nbsp; result=pthread_create(&amp;nt, NULL, f, NULL);</div><div>&nbsp; &nbsp; if(result!=0){ //线程创建失败</div><div>&nbsp; &nbsp; &nbsp; &nbsp; printf("create thread error!\n");</div><div>&nbsp; &nbsp; &nbsp; &nbsp; exit(1);</div><div>&nbsp; &nbsp; }</div><div>&nbsp; &nbsp; printid("main thread: ");</div><div>&nbsp; &nbsp; sleep(1); //用sleep函数起到延迟的作用</div><div>&nbsp; &nbsp; exit(0);</div><div>}</div><div><br></div><div>显示：</div><div>long1lfw@ubuntu:~/桌面$ gcc a.c -o a -lpthread</div><div>long1lfw@ubuntu:~/桌面$ ./a</div><div>main thread: &nbsp;pid is 3059, tid is 3079514928</div><div>new thread: &nbsp;pid is 3059, tid is 3079506800</div><div><br></div><div>Linux线程的终止</div><div>1.从线程函数return. 这对主线程不适用，从main函数return相当于调用exit.</div><div>2.一个线程可以调用pthread_cancel终止同一进程中的另一个线程</div><div>3.线程可以调用pthread_exit终止自己</div><div><br></div><div><b><font color="#0000ff"  >线程互斥，线程同步通信</font></b>等问题一直是线程控制中的重点和难点，经典例子“生产者——消费者问题”。</div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >(long1&nbsp;vs&nbsp;longpo&nbsp;转载请注明出处：</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px;"  ><a style="color: rgb(80, 80, 80); text-decoration: none; " href="http://blog.163.com/lfw2565295@126"  ><span style="line-height: 25px; color: rgb(0, 0, 255); text-decoration: underline; font-size: 10.5pt; font-family: 宋体;"  >http://blog.163.com/lfw2565295@126</span></a></span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >)</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 'Times New Roman';"  >&nbsp;</span></div><wbr></div>]]></description>
	    <author><![CDATA[long1]]></author>
	    <comments>http://blog.163.com/lfw2565295@126/blog/static/12200516201232293058547</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/lfw2565295@126/blog/static/12200516201232293058547</guid>
    <pubDate>Sun, 22 Apr 2012 09:30:58 +0800</pubDate>
    <dcterms:modified>2012-04-22T09:30:58+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[ubuntu tomcat 安装(配置环境)]]></title>	
    <link>http://blog.163.com/lfw2565295@126/blog/static/12200516201232134440396</link>
    <description><![CDATA[<div><div><font size="4"  color="#0000ff"  ><b><span style="font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px;"  >&nbsp;</span><span style="font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px;"  >安装前，先要成功安装jdk;</span></b></font><span style="color: rgb(138, 134, 121); font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px;"  ><p style="line-height: 25px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><a rel="nofollow" href="http://tomcat.apache.org/"  >http://tomcat.apache.org/</a>&nbsp; 下载tomcat</p></span><span style="font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px;"  ><p style="color: rgb(138, 134, 121); line-height: 25px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ></p><div><img title="ubuntu tomcat 安装(配置环境) - long1 - long1 vs longpo"  alt="ubuntu tomcat 安装(配置环境) - long1 - long1 vs longpo"  style="margin:0 10px 0 0;"  src="http://img0.ph.126.net/dwsR3wJA66KnSvHwFCnNwA==/1347420713531344030.jpg"  ></div><p style="line-height: 25px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><font size="3"  >下载tar.gz类型文件</font></p><p style="line-height: 25px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><font size="3"  >放到桌面(Desktop)上，命令</font></p></span><span style="font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px;"  ><p style="line-height: 25px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><font size="4"  style="line-height: 32px;"  color="#0000ff"  ><b>sudo tar zxvf filename 解压</b></font></p></span><span style="font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 32px; font-size: large;"  ><p style="color: rgb(138, 134, 121); line-height: 32px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  >在终端输入：</p><p style="line-height: 32px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  >$sudo gedit /etc/profile&nbsp;&nbsp;</font></b><br style="line-height: 32px;"  ><font color="#8a8679"  >在profile文件后加入以下内容：</font></p><p style="color: rgb(138, 134, 121); line-height: 32px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  >JAVA_HOME=/home/liufupanhao/jdk1.6.0_21<br style="line-height: 32px;"  >export JRE_HOME=/home/liufupanhao/jdk1.6.0_21/jre<br style="line-height: 32px;"  >export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH<br style="line-height: 32px;"  >export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH<br style="line-height: 32px;"  >export CATALINA_HOME=/home/liufupanhao/apache-tomcat-7.0.0</p><p style="color: rgb(138, 134, 121); line-height: 32px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  >如图：</p></span><span style="color: rgb(138, 134, 121); font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 32px; font-size: large;"  >注前面四行为安装jdk时加入的，如最后一行是安装tomcat是加入的保存退出</span><span style="color: rgb(138, 134, 121); font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 32px; font-size: large;"  ><p style="line-height: 32px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ></p><div><img title="ubuntu tomcat 安装(配置环境) - long1 - long1 vs longpo"  alt="ubuntu tomcat 安装(配置环境) - long1 - long1 vs longpo"  style="margin:0 10px 0 0;"  src="http://img1.ph.126.net/75PbymUCzc3XaKLHJwG_Iw==/1344605963764233401.jpg"  ></div>&nbsp;</span><span style="font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 32px; font-size: large;"  ><p style="color: rgb(138, 134, 121); line-height: 32px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  >在终端输入：</p><p style="line-height: 32px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  >sudo gedit .bashrc</font></b></p><p style="color: rgb(138, 134, 121); line-height: 32px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  >打开bashrc，在bashrc最后加入：</p><p style="color: rgb(138, 134, 121); line-height: 32px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  >JAVA_HOME=/home/liufupanhao/jdk1.6.0_21<br style="line-height: 32px;"  >export JRE_HOME=/home/liufupanhao/jdk1.6.0_21/jre<br style="line-height: 32px;"  >export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH<br style="line-height: 32px;"  >export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH<br style="line-height: 32px;"  >export CATALINA_HOME=/home/liufupanhao/apache-tomcat-7.0.0&nbsp;</p><p style="color: rgb(138, 134, 121); line-height: 32px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  >如图：</p></span><span style="color: rgb(138, 134, 121); font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 32px; font-size: large;"  >保存退出，重新启动系统</span><span style="color: rgb(138, 134, 121); font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 32px; font-size: large;"  ><p style="line-height: 32px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ></p><div><img title="ubuntu tomcat 安装(配置环境) - long1 - long1 vs longpo"  alt="ubuntu tomcat 安装(配置环境) - long1 - long1 vs longpo"  style="margin:0 10px 0 0;"  src="http://img9.ph.126.net/RFnmaLVYff8VzdzvxaE9QA==/1304355042094606529.jpg"  ></div>&nbsp;</span><span style="font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 32px; font-size: large;"  ><p style="color: rgb(138, 134, 121); line-height: 32px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  >重启后打开终端输入：</p><p style="line-height: 32px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><b><font color="#0000ff"  >sudo gedit&nbsp; /home/liufupanhao/apache-tomcat-7.0.0/bin/catalina.sh</font></b></p><p style="color: rgb(138, 134, 121); line-height: 32px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  >打开catalina.sh，在catalina.sh的开头加入：</p><p style="color: rgb(138, 134, 121); line-height: 32px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  >JAVA_HOME=/home/liufupanhao/jdk1.6.0_21</p><p style="color: rgb(138, 134, 121); line-height: 32px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  >如图：</p></span><span style="color: rgb(138, 134, 121); font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 32px; font-size: large;"  >保存退出：</span><span style="color: rgb(138, 134, 121); font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 32px; font-size: large;"  ><p style="line-height: 32px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ></p><div><img title="ubuntu tomcat 安装(配置环境) - long1 - long1 vs longpo"  alt="ubuntu tomcat 安装(配置环境) - long1 - long1 vs longpo"  style="margin:0 10px 0 0;"  src="http://img2.ph.126.net/brX7TWdhAwT5lWhK6QmFRQ==/2395352051825107262.jpg"  ></div>&nbsp;</span><span style="font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 32px; font-size: large;"  ><p style="line-height: 32px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><font color="#0000ff"  ><b>在终端输入：sudo /home/liufupanhao/apache-tomcat-7.0.0/bin/startup.sh&nbsp;&nbsp;</b></font></p><p style="line-height: 32px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><font color="#0000ff"  ><b>启动tomcat (windows下是.bat启动，在linux下，.sh启动，同时也要.sh关闭)</b></font></p><p style="color: rgb(138, 134, 121); line-height: 32px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ></p><div><img title="ubuntu tomcat 安装(配置环境) - long1 - long1 vs longpo"  alt="ubuntu tomcat 安装(配置环境) - long1 - long1 vs longpo"  style="margin:0 10px 0 0;"  src="http://img4.ph.126.net/ZdmxWh-011OwK2sb_403sw==/1119988932349130824.jpg"  ></div>&nbsp;</span><span style="font-family: Arial, Helvetica, simsun, u5b8bu4f53;"  ><div style="font-size: large; line-height: 32px;"  ><font color="#0000ff"  ><b>关闭tomcat</b></font></div><div style="font-size: large; line-height: 32px;"  ><font color="#0000ff"  ><b>sudo /home/liufupanhao/apache-tomcat-7.0.0/bin/shutdown.sh</b></font></div><div style="font-size: large; color: rgb(138, 134, 121); line-height: 32px;"  ><br></div><div><font color="#0000ff"  size="4"  ><b>接下来是注意的地方：</b></font></div></span></div><font size="4"  >命令 &nbsp;whereis java &nbsp;可以找jdk位置<br>jre 在 jdk1.6.0_31 里面</font><div><font size="4"  ><br></font><div><font size="4"  ><b><font color="#0000ff"  >我电脑的环境变量为：</font></b><br>JAVA_HOME=/usr/share/jdk1.6.0_31/<br>export JRE_HOME=/usr/share/jdk1.6.0_31/jre<br>export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH<br>export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH<br>export CATALINA_HOME=/home/coach/Desktop/apache-tomcat-7.0.27<br><br></font></div><div><font size="4"  ><font color="#0000ff"  ><b>server里修改端口号，http默认为80，所以把8080改为80，然后可以设置虚拟路径</b></font><br></font><font size="4"  >&lt;Context docBase="/home/coach/Desktop/pc2-9.2.1/bin/html" path="/rank"/&gt;<br><font color="#0000ff"  ><br></font></font></div><div><font size="4"  ><font color="#0000ff"  ><b>注意，这个路径目录下要有个WEB-INF文件，里面保存web.xml，如添加首页信息：</b></font></font></div><div></div><div></div><div></div><div></div><div></div><div></div><div><font size="4"  >&nbsp; &lt;welcome-file-list&gt; <br>&nbsp;&nbsp;&nbsp; &lt;welcome-file&gt;summary.html&lt;/welcome-file&gt; <br>&nbsp; &lt;/welcome-file-list&gt;</font><br></div></div></div>]]></description>
	    <author><![CDATA[long1]]></author>
	    <comments>http://blog.163.com/lfw2565295@126/blog/static/12200516201232134440396</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/lfw2565295@126/blog/static/12200516201232134440396</guid>
    <pubDate>Sat, 21 Apr 2012 15:44:40 +0800</pubDate>
    <dcterms:modified>2012-04-21T16:09:32+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[Linux进程间通信 (C语言实现)]]></title>	
    <link>http://blog.163.com/lfw2565295@126/blog/static/12200516201232044549797</link>
    <description><![CDATA[<div><div><b><font color="#0000ff"  >几个命令：</font></b></div><div><b><font color="#0000ff"  >cat filename 显示文件内容</font></b></div><div><b><font color="#0000ff"  >wc -l filename 显示文件行数列数</font></b></div><div><b><font color="#0000ff"  >grep word filename 搜索文件中"word"字符所在的行</font></b></div><div><b><font color="#0000ff"  >date +%D 输出 mm/dd/yy</font></b></div><div>具体都可以用</div><div>man 命令</div><div>来查看，用q退出man</div><div><br></div><div>回到正题，Linux进程间通信，方式有很多，这里介绍信号量，管道，消息队列</div><div><font color="#0000ff"  ><b>1.信号量</b></font></div><div>常见的信号有：SIGINT 程序终止(interrupt)，用户键入INTR字符(通常是ctrl+c)时发出</div><div>SIGTSTP 在用户按下挂起建(一般ctrl+z)时，系统会发出此信号，会造成进程挂起</div><div>SIGKILL和SEGSTOP这两个信号是应用程序无法捕捉和忽略的</div><div>常用函数有kill 发送信号SIGKILL给进程或进程组</div><div>raise 发信号给进程或自身</div><div>例子：</div><div>#include&lt;stdio.h&gt;</div><div>#include&lt;stdlib.h&gt;</div><div>#include&lt;unistd.h&gt;</div><div>#include&lt;sys/types.h&gt;</div><div>#include&lt;sys/wait.h&gt;</div><div>#include&lt;signal.h&gt;</div><div>int main()</div><div>{</div><div>&nbsp; &nbsp; pid_t p;</div><div>&nbsp; &nbsp; int r;</div><div>&nbsp; &nbsp; p=fork();</div><div>&nbsp; &nbsp; if(p&lt;0)</div><div>&nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; printf("failed\n");</div><div>&nbsp; &nbsp; &nbsp; &nbsp; exit(1);</div><div>&nbsp; &nbsp; }</div><div>&nbsp; &nbsp; //son pid</div><div>&nbsp; &nbsp; if(p==0)</div><div>&nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; raise(SIGSTOP);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; exit(0);</div><div>&nbsp; &nbsp; }</div><div>&nbsp; &nbsp; else</div><div>&nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; printf("son pid is:%d\n",p);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; if(waitpid(p,NULL,WNOHANG)==0) //wait for son pid over</div><div>&nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(r=kill(p,SIGKILL)==0)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf("The pid sent SIGKILL is:%d\n",p);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf("failed\n");</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit(1);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; }</div><div>}</div><div><br></div><div>显示：</div><div>son pid is:2004</div><div>The pid sent SIGKILL is:2004</div><div>系统调用kill和raise函数，简单的向某一进程发送信号，还有其它函数，需要有空拓展</div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >(long1&nbsp;vs&nbsp;longpo&nbsp;转载请注明出处：</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px;"  ><a style="color: rgb(80, 80, 80); text-decoration: none; " href="http://blog.163.com/lfw2565295@126"  ><span style="line-height: 25px; color: rgb(0, 0, 255); text-decoration: underline; font-size: 10.5pt; font-family: 宋体;"  >http://blog.163.com/lfw2565295@126</span></a></span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >)</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 'Times New Roman';"  >&nbsp;</span></div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 'Times New Roman';"  ><br></span></div><div><font color="#0000ff"  ><b>2.管道</b></font></div><div>一种最基本的IPC机制，由pipe函数创建，#include&lt;unistd.h&gt; int pipe(int filedes[2])</div><div>内核中开辟一块缓冲区(成为管道)用于通信，一端读，一端写，通过filedes参数传给用户程序两个文件描述付，filedes[0]指向管道读端，filedes[1]指向管道写端(0读1写，类似标准输入标准输出)</div><div>read(filedes[0])或write(filedes[1])读写内核缓冲区，成功调用返回0，失败返回-1</div><div>需要同源，同一个进程产生的进程，采用半双工方式，只允许单方面传输数据，步骤：</div><div>1）父进程调用pipe开辟管道，得到两个文件描述符指向管道的两端</div><div>2）父进程调用fork创建子进程，子进程也有两个文件描述符指向同一个管道</div><div>3）父进程关闭读端，子进程关闭写端，父进程写，子进程读，环形队列实现，数据从写端流入从读端流出，实现进程间通信</div><div>例子：</div><div>//pipe</div><div>#include&lt;stdio.h&gt;</div><div>#include&lt;stdlib.h&gt;</div><div>#include&lt;unistd.h&gt;</div><div>#define SIZE 100</div><div>int main(int argc,char **argv)</div><div>{</div><div>&nbsp; &nbsp; int n;</div><div>&nbsp; &nbsp; int fd[2];</div><div>&nbsp; &nbsp; pid_t p;</div><div>&nbsp; &nbsp; char str[SIZE];</div><div>&nbsp; &nbsp; if(pipe(fd)&lt;0){</div><div>&nbsp; &nbsp; &nbsp; &nbsp; printf("pipe");</div><div>&nbsp; &nbsp; &nbsp; &nbsp; exit(1);</div><div>&nbsp; &nbsp; }</div><div>&nbsp; &nbsp; p=fork();</div><div>&nbsp; &nbsp; if(p&lt;0){</div><div>&nbsp; &nbsp; &nbsp; &nbsp; printf("fork error!\n");</div><div>&nbsp; &nbsp; &nbsp; &nbsp; exit(1);</div><div>&nbsp; &nbsp; }</div><div>&nbsp; &nbsp; if(p&gt;0){</div><div>&nbsp; &nbsp; &nbsp; &nbsp; close(fd[0]);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; write(fd[1], "hello linux", 12);</div><div>&nbsp; &nbsp; }</div><div>&nbsp; &nbsp; else {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; close(fd[1]);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; n=read(fd[0], str, SIZE);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; printf("%s\n",str);</div><div>&nbsp; &nbsp; }</div><div>&nbsp; &nbsp; return 0;</div><div>}</div><div><br></div><div>显示：</div><div>hello linux</div><div>也可以父进程fork两次，把文件描述符传给两个子进程，两个子进程间通信</div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >(long1&nbsp;vs&nbsp;longpo&nbsp;转载请注明出处：</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px;"  ><a style="color: rgb(80, 80, 80); text-decoration: none; " href="http://blog.163.com/lfw2565295@126"  ><span style="line-height: 25px; color: rgb(0, 0, 255); text-decoration: underline; font-size: 10.5pt; font-family: 宋体;"  >http://blog.163.com/lfw2565295@126</span></a></span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >)</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 'Times New Roman';"  >&nbsp;</span></div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 'Times New Roman';"  ><br></span></div><div><font color="#0000ff"  ><b>3.消息队列</b></font></div><div>两个进程发送数据快，有最大尺寸限制，例子：</div><div>//information queue</div><div>#include&lt;stdio.h&gt;</div><div>#include&lt;stdlib.h&gt;</div><div>#include&lt;unistd.h&gt;</div><div>#include&lt;sys/types.h&gt;</div><div>#include&lt;sys/msg.h&gt;</div><div>#include&lt;sys/ipc.h&gt;</div><div>#include&lt;string.h&gt;</div><div><br></div><div>#define SIZE 256</div><div><br></div><div>struct message{</div><div>&nbsp; &nbsp; long msg_type;</div><div>&nbsp; &nbsp; char msg_text[SIZE];</div><div>};</div><div><br></div><div>int main(int argc,char **argv)</div><div>{</div><div>&nbsp; &nbsp; int qid;</div><div>&nbsp; &nbsp; key_t key;</div><div>&nbsp; &nbsp; int len;</div><div>&nbsp; &nbsp; struct message msg;</div><div>&nbsp; &nbsp; if((key=ftok(".",'a'))==-1){</div><div>&nbsp; &nbsp; &nbsp; &nbsp; printf("key error!\n");</div><div>&nbsp; &nbsp; &nbsp; &nbsp; exit(1);</div><div>&nbsp; &nbsp; }</div><div>&nbsp; &nbsp; if((qid=msgget(key,IPC_CREAT|0666))==-1){</div><div>&nbsp; &nbsp; &nbsp; &nbsp; printf("create queue error!\n");</div><div>&nbsp; &nbsp; &nbsp; &nbsp; exit(1);</div><div>&nbsp; &nbsp; }</div><div>&nbsp; &nbsp; printf("create, open queue id is: %d\n",qid);</div><div>&nbsp; &nbsp; printf("input content to queue:\n");</div><div>&nbsp; &nbsp; if((fgets((&amp;msg)-&gt;msg_text, SIZE, stdin))==NULL){</div><div>&nbsp; &nbsp; &nbsp; &nbsp; printf("no information!\n");</div><div>&nbsp; &nbsp; &nbsp; &nbsp; exit(1);</div><div>&nbsp; &nbsp; }</div><div>&nbsp; &nbsp; msg.msg_type=getpid();</div><div>&nbsp; &nbsp; len=strlen(msg.msg_text);</div><div>&nbsp; &nbsp; if((msgsnd(qid, &amp;msg, len, 0))&lt;0){</div><div>&nbsp; &nbsp; &nbsp; &nbsp; printf(" add message error!\n");</div><div>&nbsp; &nbsp; &nbsp; &nbsp; exit(1);</div><div>&nbsp; &nbsp; }</div><div>&nbsp; &nbsp; if((msgrcv(qid, &amp;msg, SIZE, 0, 0))&lt;0){</div><div>&nbsp; &nbsp; &nbsp; &nbsp; printf("read information error!\n");</div><div>&nbsp; &nbsp; &nbsp; &nbsp; exit(1);</div><div>&nbsp; &nbsp; }</div><div>&nbsp; &nbsp; printf("information is: %s\n",(&amp;msg)-&gt;msg_text);</div><div>&nbsp; &nbsp; if((msgctl(qid, IPC_RMID, NULL))&lt;0){</div><div>&nbsp; &nbsp; &nbsp; &nbsp; printf("delete information queue error!\n");</div><div>&nbsp; &nbsp; &nbsp; &nbsp; exit(1);</div><div>&nbsp; &nbsp; }</div><div>&nbsp; &nbsp; exit(0);</div><div>}</div><div><br></div><div>显示：</div><div>long1lfw@ubuntu:~/桌面$ gcc -o a a.c</div><div>long1lfw@ubuntu:~/桌面$ ./a</div><div>create, open queue id is: 0</div><div>input content to queue:</div><div>hello queue</div><div>information is: hello queue</div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >(long1&nbsp;vs&nbsp;longpo&nbsp;转载请注明出处：</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px;"  ><a style="color: rgb(80, 80, 80); text-decoration: none; " href="http://blog.163.com/lfw2565295@126"  ><span style="line-height: 25px; color: rgb(0, 0, 255); text-decoration: underline; font-size: 10.5pt; font-family: 宋体;"  >http://blog.163.com/lfw2565295@126</span></a></span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >)</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 'Times New Roman';"  >&nbsp;</span></div></div>]]></description>
	    <author><![CDATA[long1]]></author>
	    <comments>http://blog.163.com/lfw2565295@126/blog/static/12200516201232044549797</comments>
    <slash:comments>2</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/lfw2565295@126/blog/static/12200516201232044549797</guid>
    <pubDate>Fri, 20 Apr 2012 16:45:49 +0800</pubDate>
    <dcterms:modified>2012-04-20T21:55:45+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[(zz) ubuntu 软件源]]></title>	
    <link>http://blog.163.com/lfw2565295@126/blog/static/1220051620123201108924</link>
    <description><![CDATA[<div><br>ubuntu sources<wbr><p><span><font color="#38761d"  >默认的中国源速度非常不错</font></span></p> <p><span><font color="#38761d"  >在终端输入并运行 <br> sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup （备份当前的源列表，以便日後需要时恢复） <br> sudo gedit /etc/apt/sources.list （修改sources.list文件中源的列表） <br> </font></span></p> <p><span><font color="#38761d"  >然后 保存编辑好的文件，终端执行以下命令进行软件升级。 <br> sudo apt-get update #这一步是更新你的源列表，换源後必须执行 <br> （如果更新速度非常慢请更换源 sudo gedit /etc/apt/sources.list ） <br> sudo apt-get upgrade #这一步是更新软件 <br> 更新完软件后，再继续设置吧。 <br></font></span></p><p><span><font color="#38761d"  > 有时你可能需要使用:sudo apt-get -f install 来修复安装 <br> 因为经常会用到终端：所以把终端加到右键菜单： <br> sudo apt-get install nautilus-open-terminal <br> 这就终端就在右键菜单了可以了！！</font></span></p> <p> </p> <p><br> <font color="#38761d"  ># 台湾的官方源速度也相当不错，有时甚至快于内地的：<br> deb http://tw.archive.ubuntu.com/ubuntu lucid main restricted universe multiverse<br> deb http://tw.archive.ubuntu.com/ubuntu lucid-security main restricted universe multiverse<br> deb http://tw.archive.ubuntu.com/ubuntu lucid-updates main restricted universe multiverse<br> deb http://tw.archive.ubuntu.com/ubuntu lucid-backports main restricted universe multiverse<br> deb http://tw.archive.ubuntu.com/ubuntu lucid-proposed main restricted universe multiverse<br> deb-src http://tw.archive.ubuntu.com/ubuntu lucid main restricted universe multiverse<br> deb-src http://tw.archive.ubuntu.com/ubuntu lucid-security main restricted universe multiverse<br> deb-src http://tw.archive.ubuntu.com/ubuntu lucid-updates main restricted universe multiverse<br> deb-src http://tw.archive.ubuntu.com/ubuntu lucid-backports main restricted universe multiverse<br> deb-src http://tw.archive.ubuntu.com/ubuntu lucid-proposed main restricted universe multiverse<br> <br> # 骨头兄亲自搭建并维护这个Ubuntu源（该源位于浙江杭州百兆共享宽带的电信机房)：<br> deb http://ubuntu.srt.cn/ubuntu/ lucid main restricted universe multiverse<br> deb http://ubuntu.srt.cn/ubuntu/ lucid-security main restricted universe multiverse<br> deb http://ubuntu.srt.cn/ubuntu/ lucid-updates main restricted universe multiverse<br> deb http://ubuntu.srt.cn/ubuntu/ lucid-proposed main restricted universe multiverse<br> deb http://ubuntu.srt.cn/ubuntu/ lucid-backports main restricted universe multiverse<br> deb-src http://ubuntu.srt.cn/ubuntu/ lucid main restricted universe multiverse<br> deb-src http://ubuntu.srt.cn/ubuntu/ lucid-security main restricted universe multiverse<br> deb-src http://ubuntu.srt.cn/ubuntu/ lucid-updates main restricted universe multiverse<br> deb-src http://ubuntu.srt.cn/ubuntu/ lucid-proposed main restricted universe multiverse<br> deb-src http://ubuntu.srt.cn/ubuntu/ lucid-backports main restricted universe multiverse<br> <br> # Archive.ubuntu.com更新服务器（欧洲，此为官方源，电信网通用户使用)：<br> deb http://archive.ubuntu.com/ubuntu/ lucid main restricted universe multiverse<br> deb http://archive.ubuntu.com/ubuntu/ lucid-security main restricted universe multiverse<br> deb http://archive.ubuntu.com/ubuntu/ lucid-updates main restricted universe multiverse<br> deb http://archive.ubuntu.com/ubuntu/ lucid-proposed main restricted universe multiverse<br> deb http://archive.ubuntu.com/ubuntu/ lucid-backports main restricted universe multiverse<br> deb-src http://archive.ubuntu.com/ubuntu/ lucid main restricted universe multiverse<br> deb-src http://archive.ubuntu.com/ubuntu/ lucid-security main restricted universe multiverse<br> deb-src http://archive.ubuntu.com/ubuntu/ lucid-updates main restricted universe multiverse<br> deb-src http://archive.ubuntu.com/ubuntu/ lucid-proposed main restricted universe multiverse<br> deb http://archive.canonical.com/ lucid partner<br> deb-src http://archive.ubuntu.com/ubuntu/ lucid-backports main restricted universe multiverse</font></p> <p><font color="#38761d"  >#北京交通大学</font></p> <p><font color="#38761d"  >deb </font><a rel="nofollow"><font color="#38761d"  >http://mirror.bjtu.edu.cn/ubuntu/</font></a><font color="#38761d"  > karmic main multiverse restricted universe</font></p> <p><font color="#38761d"  >deb </font><a rel="nofollow"><font color="#38761d"  >http://mirror.bjtu.edu.cn/ubuntu/</font></a><font color="#38761d"  > karmic-backports main multiverse restricted universe</font></p> <p><font color="#38761d"  >deb </font><a rel="nofollow"><font color="#38761d"  >http://mirror.bjtu.edu.cn/ubuntu/</font></a><font color="#38761d"  > karmic-proposed main multiverse restricted universe</font></p> <p><font color="#38761d"  >deb </font><a rel="nofollow"><font color="#38761d"  >http://mirror.bjtu.edu.cn/ubuntu/</font></a><font color="#38761d"  > karmic-security main multiverse restricted universe</font></p> <p><font color="#38761d"  >deb </font><a rel="nofollow"><font color="#38761d"  >http://mirror.bjtu.edu.cn/ubuntu/</font></a><font color="#38761d"  > karmic-updates main multiverse restricted universe</font></p> <p><font color="#38761d"  >deb-src </font><a rel="nofollow"><font color="#38761d"  >http://mirror.bjtu.edu.cn/ubuntu/</font></a><font color="#38761d"  > karmic main multiverse restricted universe</font></p> <p><font color="#38761d"  >deb-src </font><a rel="nofollow"><font color="#38761d"  >http://mirror.bjtu.edu.cn/ubuntu/</font></a><font color="#38761d"  > karmic-backports main multiverse restricted universe</font></p> <p><font color="#38761d"  >deb-src </font><a rel="nofollow"><font color="#38761d"  >http://mirror.bjtu.edu.cn/ubuntu/</font></a><font color="#38761d"  > karmic-proposed main multiverse restricted universe</font></p> <p><font color="#38761d"  >deb-src </font><a rel="nofollow"><font color="#38761d"  >http://mirror.bjtu.edu.cn/ubuntu/</font></a><font color="#38761d"  > karmic-security main multiverse restricted universe</font></p> <p><font color="#38761d"  >deb-src </font><a rel="nofollow"><font color="#38761d"  >http://mirror.bjtu.edu.cn/ubuntu/</font></a><font color="#38761d"  > karmic-updates main multiverse restricted universe</font></p> <p><font color="#38761d"  >#江苏双线</font></p> <p><font color="#38761d"  >deb </font><a rel="nofollow"><font color="#38761d"  >http://mirror.lupaworld.com/ubuntu</font></a><font color="#38761d"  > karmic main restricted universe multiverse</font></p> <p><font color="#38761d"  >deb </font><a rel="nofollow"><font color="#38761d"  >http://mirror.lupaworld.com/ubuntu</font></a><font color="#38761d"  > karmic-security main restricted universe multiverse</font></p> <p><font color="#38761d"  >deb </font><a rel="nofollow"><font color="#38761d"  >http://mirror.lupaworld.com/ubuntu</font></a><font color="#38761d"  > karmic-updates main restricted universe multiverse</font></p> <p><font color="#38761d"  >deb </font><a rel="nofollow"><font color="#38761d"  >http://mirror.lupaworld.com/ubuntu</font></a><font color="#38761d"  > karmic-backports main restricted universe multiverse</font></p> <p><font color="#38761d"  >deb </font><a rel="nofollow"><font color="#38761d"  >http://mirror.lupaworld.com/ubuntu/ubuntu-cn</font></a><font color="#38761d"  > karmic main restricted universe multiverse</font></p> <p><font color="#38761d"  >deb </font><a rel="nofollow"><font color="#38761d"  >http://mirror.lupaworld.com/ubuntu/</font></a><font color="#38761d"  > karmic-proposed main restricted universe multiverse</font></p> <p><font color="#38761d"  >deb-src </font><a rel="nofollow"><font color="#38761d"  >http://mirror.lupaworld.com/ubuntu</font></a><font color="#38761d"  > karmic main restricted universe multiverse</font></p> <p><font color="#38761d"  >deb-src </font><a rel="nofollow"><font color="#38761d"  >http://mirror.lupaworld.com/ubuntu</font></a><font color="#38761d"  > karmic-security main restricted universe multiverse</font></p> <p><font color="#38761d"  >deb-src </font><a rel="nofollow"><font color="#38761d"  >http://mirror.lupaworld.com/ubuntu</font></a><font color="#38761d"  > karmic-updates main restricted universe multiverse</font></p> <p><font color="#38761d"  >deb-src </font><a rel="nofollow"><font color="#38761d"  >http://mirror.lupaworld.com/ubuntu</font></a><font color="#38761d"  > karmic-backports main restricted universe multiverse</font></p> <p><font color="#38761d"  >deb-src </font><a rel="nofollow"><font color="#38761d"  >http://mirror.lupaworld.com/ubuntu/</font></a><font color="#38761d"  > karmic-proposed main restricted universe multiverse</font></p></div>]]></description>
	    <author><![CDATA[long1]]></author>
	    <comments>http://blog.163.com/lfw2565295@126/blog/static/1220051620123201108924</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/lfw2565295@126/blog/static/1220051620123201108924</guid>
    <pubDate>Fri, 20 Apr 2012 11:00:08 +0800</pubDate>
    <dcterms:modified>2012-04-20T11:00:08+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[Linux下进程控制 (C语言实现)]]></title>	
    <link>http://blog.163.com/lfw2565295@126/blog/static/12200516201231961317839</link>
    <description><![CDATA[<div><div>Linux环境下，每个正在运行的程序都称为进程，它相当于Windows系统中的任务，可以用top查看用q退出，或ps -aux查看具体。每个进程包含进程标识符及数据，这些数据包含进程变量、外部变量和进程栈等。</div><div><br></div><div><font color="#0000ff"  ><b>进程和程序的区别：</b></font></div><div>1.程序是指令的有序集合，其本身没有任何运行的意义，是一个静态的概念。而进程是程序在处理机上的一次执行过程，它是一个动态的概念。</div><div>2.程序可以作为一种软件长期存在，而进程是有一定生命期的。程序是永久的，进程是暂时的。</div><div>3.进程更能真实地描述并发，而程序不能；进程是由程序和数据两部分组成的。</div><div>4.进程具有创建其它进程的功能，程序没有。</div><div>5.同一程序运行于若干个数据集合上，它将属于若干个不同的进程。也就是说同一程序可以对应多个进程。</div><div>6.在传统的操作系统中，程序并不能独立运行，作为资源分配和独立运行的基本单位都是进程。</div><div><br></div><div>每个进程在内核中都有一个进程控制块(PCB)来维护进程相关的信息，Linux内核的进程控制块是task_stuct结构体。每个进程有唯一id,C语言中用pid_t类型表示，其实就是一个非负整数。进程状态有“就绪”，“运行”，“阻塞”，“挂起(睡眠)”，“停止”，“僵尸”等状态。进程中包含的信息都保存在PCB中。</div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >(long1&nbsp;vs&nbsp;longpo&nbsp;转载请注明出处：</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px;"  ><a style="color: rgb(80, 80, 80); text-decoration: none; " href="http://blog.163.com/lfw2565295@126"  ><span style="line-height: 25px; color: rgb(0, 0, 255); text-decoration: underline; font-size: 10.5pt; font-family: 宋体;"  >http://blog.163.com/lfw2565295@126</span></a></span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >)</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 'Times New Roman';"  >&nbsp;</span></div><div><br></div><div><font color="#0000ff"  ><b>pid是进程号，ppid是父进程号，他们都是正整数。使用getpid,getppid获得：</b></font></div><div><font color="#0000ff"  ><b>vim p.c</b></font></div><div>进入vim输入"i"进入编辑模式，输入代码：</div><div>#include&lt;unistd.h&gt; &nbsp;//别忘了这个头文件</div><div>#include&lt;stdio.h&gt;</div><div>int main(int argc,char **argv){</div><div>&nbsp; printf("进程号:%d, 父进程号:%d\n",getpid(),getppid());</div><div>&nbsp; return 0;</div><div>}</div><div>"ESC"切换到命令模式， ":wq"保存退出</div><div>然后运行：</div><div>long1lfw@ubuntu:~/桌面$ vim p.c</div><div>long1lfw@ubuntu:~/桌面$ gcc p.c -o p</div><div>long1lfw@ubuntu:~/桌面$ ./p</div><div>进程号:3829, 父进程号:3138</div><div>多次运行，pid都不一样(逐渐变大),ppid一样，许多程序利用取得的pid值来建立临时文件，以避免临时文件相同带来的问题。</div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >(long1&nbsp;vs&nbsp;longpo&nbsp;转载请注明出处：</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px;"  ><a style="color: rgb(80, 80, 80); text-decoration: none; " href="http://blog.163.com/lfw2565295@126"  ><span style="line-height: 25px; color: rgb(0, 0, 255); text-decoration: underline; font-size: 10.5pt; font-family: 宋体;"  >http://blog.163.com/lfw2565295@126</span></a></span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >)</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 'Times New Roman';"  >&nbsp;</span></div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 'Times New Roman';"  ><br></span></div><div><font color="#0000ff"  ><b>进程创建</b></font></div><div><font color="#0000ff"  ><b>1.exec</b></font></div><div>有六种，execve是真正的系统调用函数，其它五个是库函数，最终都会调用execve.</div><div>int execve(const char *path, char *const argv[], char *const envp[]);</div><div>path是要被执行的程序的路径， argv命令行参数（命令的集合）, envp传递环境变量</div><div><b><font color="#0000ff"  >const例子</font>：</b></div><div>这里是const char *p; “自以为指向常量的指针”,指针地址值可以增减(p++可以)，也可以给指针更换指向的常量，但不可以直接通过(*p)='b'来改变，例子程序：</div><div>#include&lt;unistd.h&gt;</div><div>#include&lt;stdio.h&gt;</div><div>int main(int argc,char **argv){</div><div>&nbsp; &nbsp;const char *p;&nbsp;</div><div>&nbsp; &nbsp;char c='a';</div><div>&nbsp; &nbsp;p=&amp;c;</div><div>&nbsp; &nbsp;printf("c=%c\n",*p);</div><div>&nbsp; &nbsp;c='b'; &nbsp;//(*p)='b'; 这个不可以</div><div>&nbsp; &nbsp;printf("c=%c\n",*p);</div><div>}</div><div>输出：c=a &nbsp; c=b</div><div>类似const int p; p的值就不能变了，p为常量,上面p变为*p,所以*p的值不能变； const char *p和char const *p一样（所以本质上就看const 和 p还是*p）；</div><div><br></div><div>char * const p 指向不变，内容可以用(*p)来修改，是一个“长指针”，例子程序：</div><div>#include&lt;unistd.h&gt;</div><div>#include&lt;stdio.h&gt;</div><div>int main(int argc,char **argv){</div><div>&nbsp; &nbsp;char c='a';</div><div>&nbsp; &nbsp;char b='d';</div><div>&nbsp; &nbsp;char *const p=&amp;c;</div><div>&nbsp; &nbsp;printf("c=%c ",*p);</div><div>&nbsp; &nbsp;c='b';</div><div>&nbsp; &nbsp;printf("c=%c ",*p);</div><div>&nbsp; &nbsp;(*p)='c'; //p=&amp;b; 这个不可以</div><div>&nbsp; &nbsp;printf("c=%c\n",*p);</div><div>}</div><div>对c，(*p)操作都可以，唯一不可操作的是p=&amp;b,也就是说，p指向的地址不能变，地址里的东西可以变</div><div><br></div><div>回到正题，使用execve()函数，例子：</div><div>#include&lt;unistd.h&gt;</div><div>#include&lt;stdio.h&gt;</div><div>int main(int argc,char **argv){</div><div>&nbsp; &nbsp;char *str[]={"ls", NULL};</div><div>&nbsp; &nbsp;printf("当前进程的进程号为:%d\n", getpid());</div><div>&nbsp; &nbsp;if(execve("/bin/ls", str, NULL)&lt;0) printf("execve error!");</div><div>&nbsp; &nbsp;return 0;</div><div>}</div><div>long1lfw@ubuntu:~/桌面$ vim p.c</div><div>long1lfw@ubuntu:~/桌面$ gcc p.c -o p</div><div>long1lfw@ubuntu:~/桌面$ ./p</div><div>当前进程的进程号为:5738</div><div>250<span style="white-space:pre;"  >   </span> &nbsp; eclipse.desktop<span style="white-space:pre;"  > </span> &nbsp;p.c</div><div>ContestAppletProd.jnlp<span style="white-space:pre;"  > </span> &nbsp; google-chrome.desktop &nbsp;?????????</div><div>codeblocks.desktop<span style="white-space:pre;"  > </span> &nbsp; netbeans.desktop<span style="white-space:pre;"  > </span> &nbsp;??????????????????</div><div>com.qq.web.webtop.desktop &nbsp;p</div><div>这个和直接命令里输入 ls类似，文字编码不一样：</div><div>long1lfw@ubuntu:~/桌面$ ls</div><div>250 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;eclipse.desktop &nbsp; &nbsp; &nbsp; &nbsp;p.c</div><div>codeblocks.desktop &nbsp; &nbsp; &nbsp; &nbsp; google-chrome.desktop &nbsp;未命名文件夹</div><div>com.qq.web.webtop.desktop &nbsp;netbeans.desktop &nbsp; &nbsp; &nbsp; 新文件</div><div>ContestAppletProd.jnlp &nbsp; &nbsp; p</div><div><br></div><div>在使用exec函数族的时候，加上错误判断语句，失败时往往因为“找不到文件路径”</div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >(long1&nbsp;vs&nbsp;longpo&nbsp;转载请注明出处：</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px;"  ><a style="color: rgb(80, 80, 80); text-decoration: none; " href="http://blog.163.com/lfw2565295@126"  ><span style="line-height: 25px; color: rgb(0, 0, 255); text-decoration: underline; font-size: 10.5pt; font-family: 宋体;"  >http://blog.163.com/lfw2565295@126</span></a></span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >)</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 'Times New Roman';"  >&nbsp;</span></div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 'Times New Roman';"  ><br></span></div><div><font color="#0000ff"  ><b>2.system函数</b></font></div><div>函数原型include&lt;stdlib.h&gt; int system(cosnt char *string);</div><div>system()会调用fork()产生子进程，由子进程来调用/bin/sh -c string来执行参数string字符串所代表的命令，此命令执行完后随即返回原调用的进程。在调用system()期间SIGCHLD信号会被暂时搁置，SIGINT和SIGQUIT信号则会被忽略。</div><div>返回值： =-1: 出现错误</div><div>&nbsp; &nbsp; &nbsp; &nbsp;=0：调用成功，但没有出现子进程</div><div>&nbsp; &nbsp; &nbsp; &nbsp;&gt;0：成功退出的子进程的id</div><div>如果system()在调用/bin/sh 时失败则返回127,其他失败原因返回-1，看个例子：</div><div>#include&lt;stdlib.h&gt;</div><div>#include&lt;stdio.h&gt;</div><div>int main(int argc,char **argv){</div><div>&nbsp; &nbsp;int t;</div><div>&nbsp; &nbsp;printf("当前进程号是：%d\n",getpid());</div><div>&nbsp; &nbsp;t=system("ls -l");</div><div>&nbsp; &nbsp;printf("t=%d\n",t);</div><div>&nbsp; &nbsp;return 0;</div><div>}</div><div><br></div><div>运行： （运行了ls -l 的命令）</div><div>long1lfw@ubuntu:~/桌面$ vim p.c</div><div>long1lfw@ubuntu:~/桌面$ gcc p.c -o p</div><div>long1lfw@ubuntu:~/桌面$ ./p</div><div>当前进程号是：2363</div><div>总计 60</div><div>-rw-r--r-- 1 long1lfw long1lfw 1894 2012-01-11 11:40 250</div><div>-rwxr-xr-x 1 long1lfw long1lfw &nbsp;323 2011-11-11 11:09 codeblocks.desktop</div><div>-rwx------ 1 long1lfw long1lfw &nbsp;344 2011-11-10 18:17 com.qq.web.webtop.desktop</div><div>-rw-r--r-- 1 long1lfw long1lfw &nbsp;962 2011-11-11 16:55 ContestAppletProd.jnlp</div><div>-rwxr-xr-x 1 long1lfw long1lfw &nbsp;195 2011-11-11 11:09 eclipse.desktop</div><div>-rwxr-xr-x 1 long1lfw long1lfw 8467 2011-11-10 18:01 google-chrome.desktop</div><div>-rw-r--r-- 1 long1lfw long1lfw 4760 2012-04-19 16:37 Linux下进程控制</div><div>-rwxr-xr-x 1 long1lfw long1lfw &nbsp;283 2011-11-11 11:09 netbeans.desktop</div><div>-rwxr-xr-x 1 long1lfw long1lfw 7229 2012-04-19 16:43 p</div><div>-rw-r--r-- 1 long1lfw long1lfw &nbsp;165 2012-04-19 16:43 p.c</div><div>drwxr-xr-x 3 long1lfw long1lfw 4096 2012-04-18 11:29 未命名文件夹</div><div>t=0</div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >(long1&nbsp;vs&nbsp;longpo&nbsp;转载请注明出处：</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px;"  ><a style="color: rgb(80, 80, 80); text-decoration: none; " href="http://blog.163.com/lfw2565295@126"  ><span style="line-height: 25px; color: rgb(0, 0, 255); text-decoration: underline; font-size: 10.5pt; font-family: 宋体;"  >http://blog.163.com/lfw2565295@126</span></a></span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >)</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 'Times New Roman';"  >&nbsp;</span></div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 'Times New Roman';"  ><br></span></div><div><font color="#0000ff"  ><b>3.fork函数</b></font></div><div>作用是根据一个现有的进程复制出一个新进程，原来的进程成为父进程，新进程为子进程。shell下输入命令可以运行一个程序，是因为shell进程在读取用户输入的命令后会调用fork复制出一个新的shell进程，然后新的shell进程调用exec执行新的程序</div><div><br></div><div>一个程序可以多次加载到内存成为同时运行的多个进程，如打开多个终端运行/bin/bash，另一方面，一个进程在调用exec前后也可以分别执行两个不同的程序，如shell提示符下输入ls,首先fork串建子进程，这时子进程仍在执行/bin/bash程序，然后子进程调用exec执行新的程序/bin/ls</div><div><br></div><div>用fork创建子进程后，子进程会复制父进程的数据和堆栈空间，并继承父进程的用户代码，组代码，环境变量，已经打开的文件代码，工作目录及资源限制等，但使用的内存空间不同。</div><div>原型： #include&lt;sys/types.h&gt; #include&lt;unistd.h&gt; pid_t fork(void);</div><div><br></div><div>调用失败（内存不足或用户的最大进程数已到）返回-1，否则fork返回值有很重要的作用。对于父进程fork返回子进程的ID,而对于fork子进程返回0，根据这个返回值来区分父子进程的。一旦子进程被创建，父子进程一起从fork处继续执行，相互竞争系统的资源。</div><div><br></div><div>例子：</div><div>#include&lt;stdlib.h&gt;</div><div>#include&lt;stdio.h&gt;</div><div>#include&lt;sys/types.h&gt;</div><div>#include&lt;unistd.h&gt;</div><div>int main(void){</div><div>&nbsp; &nbsp;pid_t p;</div><div>&nbsp; &nbsp;char *message;</div><div>&nbsp; &nbsp;int n;</div><div>&nbsp; &nbsp;p=fork();</div><div>&nbsp; &nbsp;if(p&lt;0) {printf("fork failed\n"); exit(1);}</div><div>&nbsp; &nbsp;if(p==0){message="This is the child\n"; n=6;}</div><div>&nbsp; &nbsp;else {message="This is the parent\n"; n=3;}</div><div>&nbsp; &nbsp;for(; n&gt;0; n--){printf("%d %s",n,message);sleep(1);}</div><div>&nbsp; &nbsp;return 0;</div><div>}</div><div>运行：</div><div>long1lfw@ubuntu:~/桌面$ vim p.c</div><div>long1lfw@ubuntu:~/桌面$ gcc p.c -o p</div><div>long1lfw@ubuntu:~/桌面$ ./p</div><div>3 This is the parent</div><div>6 This is the child</div><div>2 This is the parent</div><div>5 This is the child</div><div>1 This is the parent</div><div>4 This is the child</div><div>3 This is the child</div><div>long1lfw@ubuntu:~/桌面$ 2 This is the child</div><div>1 This is the child</div><div><br></div><div>这里sleep(1)是1s(java里貌似是1ms),当父进程结束时，shell进程认为命令执行结束了，于是打印shell提示符号，而事实上子进程还没有结束，所以子进程的消息打印到了shell提示符后面，最后光标停在1 This is the child的下一行，这时用户仍可以敲命令，即使不紧跟在提示符(long1lfw@ubuntu:~/桌面$)后面，shell也能正确读取</div><div><br></div><div><font color="#0000ff"  ><b>fork函数的特点概括起来就是“调用一次，返回两次”，在父进程中调用一次，在父进程和子进程中各返回一次,就像分叉了一样，所以才用fork这个名字</b></font>。</div><div>fork的另一个特性是所有的父进程打开的描述符都被复制到子进程中。父、子进程中相同编号的文件描述符在内核中指向统一个file结构体，也就是说，file结构体的引用计数要增加。</div><div><br></div><div><font color="#0000ff"  ><b>进程终止</b></font></div><div>滥用fork会占满系统进程，资源消耗殆尽，所以有终止，stdlib.h的exit和unistd.h_exit()，一般情况下，exit(0)表示正常退出，exit(1),exit(-1)为异常退出</div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >(long1&nbsp;vs&nbsp;longpo&nbsp;转载请注明出处：</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px;"  ><a style="color: rgb(80, 80, 80); text-decoration: none; " href="http://blog.163.com/lfw2565295@126"  ><span style="line-height: 25px; color: rgb(0, 0, 255); text-decoration: underline; font-size: 10.5pt; font-family: 宋体;"  >http://blog.163.com/lfw2565295@126</span></a></span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >)</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 'Times New Roman';"  >&nbsp;</span></div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 'Times New Roman';"  ><br></span></div><div><font color="#0000ff"  ><b>僵尸进程(zombie)</b></font></div><div>指已终止运行，但尚未被清楚的进程。如果父进程终止早，子进程还在运行，就成了僵尸进程</div><div><font color="#0000ff"  ><b>父进程通过wait和waitpid等函数等待子进程结束</b></font>，父进程挂起或阻塞。</div><div>例子：</div><div>#include&lt;stdlib.h&gt;</div><div>#include&lt;stdio.h&gt;</div><div>#include&lt;sys/types.h&gt;</div><div>#include&lt;unistd.h&gt;</div><div>#include&lt;sys/wait.h&gt;</div><div><br></div><div>int main(int argc,int **argv){</div><div>&nbsp; &nbsp;pid_t pid;</div><div>&nbsp; &nbsp;pid=fork();</div><div>&nbsp; &nbsp;if(pid&lt;0) {printf("fork failed\n"); exit(1);}</div><div>&nbsp; &nbsp;if(pid==0){int i; for(i=3; i&gt;0; i--){printf("This is child\n"); sleep(1);} exit(3);}</div><div>&nbsp; &nbsp;else {</div><div>&nbsp; &nbsp; &nbsp;int stat_val;&nbsp;</div><div>&nbsp; &nbsp; &nbsp;waitpid(pid, &amp;stat_val, 0);</div><div>&nbsp; &nbsp; &nbsp;if(WIFEXITED(stat_val)) printf("Child exited with code %d\n", WEXITSTATUS(stat_val));</div><div>&nbsp; &nbsp; &nbsp;else if(WIFSIGNALED(stat_val)) printf("Child terminated abnormally, signa %d\n",WTERMSIG(stat_val));</div><div>&nbsp; &nbsp;}</div><div>&nbsp; &nbsp;return 0;</div><div>}</div><div><br></div><div>运行：</div><div>long1lfw@ubuntu:~/桌面$ vim p.c</div><div>long1lfw@ubuntu:~/桌面$ gcc p.c -o p</div><div>long1lfw@ubuntu:~/桌面$ ./p</div><div>This is child</div><div>This is child</div><div>This is child</div><div>Child exited with code 3</div><div><br></div><div>如果子进程是正常终止的，WIFEXITED取出的字段值非零，就是子进程的退出状态；如果异常终止，WIFSIGNALED取出的是信号的编号。这些是宏定义，在头文件里可以查看相关运算，如何取出字段。</div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >(long1&nbsp;vs&nbsp;longpo&nbsp;转载请注明出处：</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px;"  ><a style="color: rgb(80, 80, 80); text-decoration: none; " href="http://blog.163.com/lfw2565295@126"  ><span style="line-height: 25px; color: rgb(0, 0, 255); text-decoration: underline; font-size: 10.5pt; font-family: 宋体;"  >http://blog.163.com/lfw2565295@126</span></a></span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 宋体;"  >)</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; background-color: rgb(251, 251, 251); text-align: justify; text-indent: 33px; font-family: 'Times New Roman';"  >&nbsp;</span></div><div><br></div><wbr></div>]]></description>
	    <author><![CDATA[long1]]></author>
	    <comments>http://blog.163.com/lfw2565295@126/blog/static/12200516201231961317839</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/lfw2565295@126/blog/static/12200516201231961317839</guid>
    <pubDate>Thu, 19 Apr 2012 18:13:17 +0800</pubDate>
    <dcterms:modified>2012-04-19T18:14:04+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[Linux 程序设计基础 gcc gdb makefile 等]]></title>	
    <link>http://blog.163.com/lfw2565295@126/blog/static/122005162012318112822957</link>
    <description><![CDATA[<div><div>pwd命令现实当前路径</div><div>long1lfw@ubuntu:~/桌面$ pwd</div><div>/home/long1lfw/桌面</div><div><br></div><div>建立a.c文件，内容：</div><div>#include&lt;stdio.h&gt;</div><div>int main(){</div><div>&nbsp; &nbsp; printf("hello world\n");</div><div>&nbsp; &nbsp; return 0;</div><div>}</div><div>然后在终端里(ctrl+alt+t): gcc a.c -o a</div><div>编译成a</div><div>然后: ./a</div><div>输出： hello world</div><div>有三种写法：</div><div>gcc file.c -o file</div><div>gcc -o file file.c</div><div>gcc file.c</div><div>前两种生成file目标文件,第三种生成file.out文件</div><div>gcc的编译过程: 源文件(*.c)-&gt;预处理(Pre-Processing)-&gt;编译(Compiling)-&gt;汇编(Assembing)-&gt;链接(Linking)-&gt;可执行文件</div><div><br></div><div>然后使用rm -v a 删除a,显示:已删除“a”</div><div>rm[必要参数][选择性参数][目录或者文件]</div><div>rm指令用来删除文件或者目录，如果使用rm来删除文件，通常仍可以将文件恢复。如果想保证该文件的内容无法复原，可以考虑使用shred指令。</div><div>必要参数具体说明如下：</div><div>参数 功能</div><div>-d 删除可能仍有数据的目录</div><div>-f 强制删除</div><div>-i 交互模式</div><div>-r 同时删除该目录下的所有目录层</div><div>-v 运行时显示详细的信息</div><div><br></div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; text-align: justify; text-indent: 33px; background-color: rgb(251, 251, 251); font-family: 宋体;"  >(long1&nbsp;vs&nbsp;longpo&nbsp;转载请注明出处：</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: justify; text-indent: 33px; background-color: rgb(251, 251, 251);"  ><a style="color: rgb(80, 80, 80); text-decoration: none; " href="http://blog.163.com/lfw2565295@126"  ><span style="line-height: 25px; color: rgb(0, 0, 255); text-decoration: underline; font-size: 10.5pt; font-family: 宋体;"  >http://blog.163.com/lfw2565295@126</span></a></span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; text-align: justify; text-indent: 33px; background-color: rgb(251, 251, 251); font-family: 宋体;"  >)</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; text-align: justify; text-indent: 33px; background-color: rgb(251, 251, 251); font-family: 'Times New Roman';"  >&nbsp;</span></div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; text-align: justify; text-indent: 33px; background-color: rgb(251, 251, 251); font-family: 'Times New Roman';"  ><br></span></div><div>gdb调试期是linux下一款GNU组织开发的程序调试工具，虽然没有友好界面，但功能强大,需要先通过gcc编译生成可执行文件后，才能用gdb调试</div><div>gcc a.c -o a -g</div><div>注意gcc编译时，最后加-g,编译好后，命令: gdb a</div><div>输出一些gdb信息，然后可以(gdb)调试了</div><div>输入: "l", 显示行号； &nbsp;"b 行号" 在相应行位置设置断点，可以用"info b"查看</div><div>如：</div><div>(gdb) l</div><div>1<span style="white-space:pre;"  > </span>#include&lt;stdio.h&gt;</div><div>2<span style="white-space:pre;"  > </span>int main(){</div><div>3<span style="white-space:pre;"  > </span> &nbsp; &nbsp;int a,b,c;</div><div>4<span style="white-space:pre;"  > </span> &nbsp; &nbsp;printf("input a,b:\n");</div><div>5<span style="white-space:pre;"  > </span> &nbsp; &nbsp;scanf("%d",&amp;a);</div><div>6<span style="white-space:pre;"  > </span> &nbsp; &nbsp;scanf("%d",&amp;b);</div><div>7<span style="white-space:pre;"  > </span> &nbsp; &nbsp;a++;</div><div>8<span style="white-space:pre;"  > </span> &nbsp; &nbsp;b++;</div><div>9<span style="white-space:pre;"  > </span> &nbsp; &nbsp;c=a+b;</div><div>10<span style="white-space:pre;"  > </span> &nbsp; &nbsp;printf("%d\n",c);</div><div>(gdb) l</div><div>11<span style="white-space:pre;"  > </span> &nbsp; &nbsp;return 0;</div><div>12<span style="white-space:pre;"  > </span>}</div><div>这里每次最多显示10行</div><div>(gdb) b 5 就设置了一个断点，然后类似设置几个，用info b查看</div><div>(gdb) info b</div><div>Num &nbsp; &nbsp; Type &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Disp Enb Address &nbsp; &nbsp;What</div><div>1 &nbsp; &nbsp; &nbsp; breakpoint &nbsp; &nbsp; keep y &nbsp; 0x08048459 in main at a.c:5</div><div>2 &nbsp; &nbsp; &nbsp; breakpoint &nbsp; &nbsp; keep y &nbsp; 0x08048483 in main at a.c:7</div><div>3 &nbsp; &nbsp; &nbsp; breakpoint &nbsp; &nbsp; keep y &nbsp; 0x0804848e in main at a.c:8</div><div><br></div><div>"r"来运行程序至断点; "p 变量名"可以观察对应变量的值</div><div>如果单步调试，可输入"s"或"n"，"s"会进入函数，"n"不会</div><div>要推出gdb环境，输入"q"，选择"y"</div><div><br></div><div>如果有四个文件a.c:</div><div>#include&lt;stdio.h&gt;</div><div>#include "file.h"</div><div>int main(){</div><div>&nbsp; &nbsp; int i;</div><div>&nbsp; &nbsp; int n=5;</div><div>&nbsp; &nbsp; int a[5]={1,2,3,4,5};</div><div>&nbsp; &nbsp; double a_sum,a_avg;</div><div>&nbsp; &nbsp; a_sum=Sum(a,n);</div><div>&nbsp; &nbsp; a_avg=Avg(a,n);</div><div>&nbsp; &nbsp; printf("sum is %f,avg is %f\n",a_sum,a_avg);</div><div>&nbsp; &nbsp; return 0;</div><div>}</div><div>b.c:</div><div>double Sum(int *a, int n){</div><div>&nbsp; &nbsp; double sum=0.0;</div><div>&nbsp; &nbsp; int i;</div><div>&nbsp; &nbsp; for(i=0; i&lt;n; i++) sum+=a[i];</div><div>&nbsp; &nbsp; return sum;</div><div>}</div><div>c.c:</div><div>double Avg(int *a, int n){</div><div>&nbsp; &nbsp;double avg=0.0;</div><div>&nbsp; &nbsp;int i;</div><div>&nbsp; &nbsp;for(i=0; i&lt;n; i++) avg+=a[i];</div><div>&nbsp; &nbsp;return avg/n;</div><div>}</div><div>file.h:</div><div>double Sum(int *a, int n);</div><div>double Avg(int *a, int n);</div><div>把他们编译运行可以： gcc a.c b.c c.c -o d</div><div>然后 long1lfw@ubuntu:~/桌面$ ./d</div><div>sum is 15.000000,avg is 3.000000</div><div>但很多文件，有时部分文件修改，不许要全部都编译，但编译器不知道哪些文件最近更新过的，所以都要重新编译，工作量就很大了。这事make工程管理器就排上用场了</div><div>make是一个“自动编译管理器”,这里的“自动”是指它能够根据文件时间戳自动发现更新过的文件而减少编译的工作量。同时，它通过读入makefile文件的内容来执行大量的编译工作。用户只需编写一次编写语句就可以了，从而大大提高了实际的工作效率。</div><div>一个makefile文件中通常包含以下内容：</div><div>1.目标体(target),通常是目标文件或可执行文件 2.目标所依赖的文件 3.创建目标时需要运行的命令</div><div><br></div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; text-align: justify; text-indent: 33px; background-color: rgb(251, 251, 251); font-family: 宋体;"  >(long1&nbsp;vs&nbsp;longpo&nbsp;转载请注明出处：</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: justify; text-indent: 33px; background-color: rgb(251, 251, 251);"  ><a style="color: rgb(80, 80, 80); text-decoration: none; " href="http://blog.163.com/lfw2565295@126"  ><span style="line-height: 25px; color: rgb(0, 0, 255); text-decoration: underline; font-size: 10.5pt; font-family: 宋体;"  >http://blog.163.com/lfw2565295@126</span></a></span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; text-align: justify; text-indent: 33px; background-color: rgb(251, 251, 251); font-family: 宋体;"  >)</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; text-align: justify; text-indent: 33px; background-color: rgb(251, 251, 251); font-family: 'Times New Roman';"  >&nbsp;</span></div><div><br></div><div>先创建一个vim makefileabc</div><div>提示： 程序“vim”已包含在下列软件包中：</div><div>&nbsp;* vim</div><div>&nbsp;* vim-gnome</div><div>&nbsp;* vim-tiny</div><div>&nbsp;* vim-gtk</div><div>&nbsp;* vim-nox</div><div>请尝试：sudo apt-get install &lt;选定的软件包&gt;</div><div>我们install简单的vim</div><div>long1lfw@ubuntu:~/桌面$ sudo apt-get install vim</div><div>vim-gnome有图形界面，也比较好</div><div>然后再 vim makefileabc</div><div>1.初始进入vi是「命令行模式（command mode）」，还不能编辑，要转换到「插入模式（Insert mode）」，按一下字母「i」就能够进入「插入模式（Insert mode）」，这时候您就能够开始输入文字了。</div><div>2.现在处于「插入模式（Insert mode）」，您就只能一直输入文字，假如您发现输错了字！想用光标键往回移动，将该字删除，就要先按一下「ESC」键转到「命令行模式（command mode）」再删除文字。 &nbsp;</div><div>3.在「命令行模式（command mode）」下，按一下「：」冒号键进入「Last line mode」，例如： &nbsp;</div><div>: w filename （输入 「w filename」将文章以指定的文档名filename保存） &nbsp;</div><div>: wq (输入「wq」，存盘并退出vi) &nbsp;</div><div>: q! (输入q!， 不存盘强制退出vi) &nbsp;</div><div>vim中功能增强了，可以回移</div><div><br></div><div>vim makefileabc输入：</div><div>abc:a.o b.o c.o</div><div>&nbsp; &nbsp; &nbsp; &nbsp; gcc a.o b.o c.o -o abc</div><div>a.o:a.c file.h</div><div>&nbsp; &nbsp; &nbsp; &nbsp; gcc a.c -c</div><div>b.o:b.c</div><div>&nbsp; &nbsp; &nbsp; &nbsp; gcc b.c -c</div><div>c.o:c.c</div><div>&nbsp; &nbsp; &nbsp; &nbsp; gcc c.c -c</div><div>[ESC] :wq 保存退出到终端</div><div>然后输入：make -f makefileabc</div><div>此时终端显示如下信息：</div><div>long1lfw@ubuntu:~/桌面$ make -f makefileabc</div><div>gcc a.c -c</div><div>gcc b.c -c</div><div>gcc c.c -c</div><div>gcc a.o b.o c.o -o abc</div><div>此时在执行abc，就可以得到之前一样的结果，代表编译和链接等过程已执行。注意的是gcc前面的空格是[Tab]形成的，不是空格建，那么makefile的书写规范：</div><div>1.目标文件： 依赖文件</div><div>2.[Tab] 产生目标文件的命令</div><div><br></div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; text-align: justify; text-indent: 33px; background-color: rgb(251, 251, 251); font-family: 宋体;"  >(long1&nbsp;vs&nbsp;longpo&nbsp;转载请注明出处：</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: justify; text-indent: 33px; background-color: rgb(251, 251, 251);"  ><a style="color: rgb(80, 80, 80); text-decoration: none; " href="http://blog.163.com/lfw2565295@126"  ><span style="line-height: 25px; color: rgb(0, 0, 255); text-decoration: underline; font-size: 10.5pt; font-family: 宋体;"  >http://blog.163.com/lfw2565295@126</span></a></span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; text-align: justify; text-indent: 33px; background-color: rgb(251, 251, 251); font-family: 宋体;"  >)</span><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; text-align: justify; text-indent: 33px; background-color: rgb(251, 251, 251); font-family: 'Times New Roman';"  >&nbsp;</span></div><div><span style="line-height: 25px; color: rgb(102, 102, 102); font-size: 10.5pt; text-align: justify; text-indent: 33px; background-color: rgb(251, 251, 251); font-family: 'Times New Roman';"  ><br></span></div><div>命令： uname</div><div>&nbsp; &nbsp;-a, --all print all information, in the followiorder:</div><div>　　-s, --kernel-name print the kernel name</div><div>　　-n, --nodename print the network node hostname</div><div>　　-r, --kernel-release print the kernel release</div><div>　　-v, --kernel-version print the kernel version</div><div>　　-m, --machine print the machine hardware name</div><div>　　-p, --processor print the processor type</div><div>　　-i, --hardware-platform print the hardware platform</div><div>　　-o, --operating-system print the operating system</div><div>&nbsp; &nbsp; &nbsp; &nbsp;解释：</div><div>&nbsp; &nbsp; uname这个是用于显示系统的信息</div><div>&nbsp; &nbsp; uname -r查看内核等，</div><div>&nbsp; &nbsp; uname -a也能得到所有的信息（linux发行商，版本号，主机名，liunx版本内核信息等）&nbsp;</div><div><br></div><div>这里主要讲了pwd,cd,rm,gcc,gdb,makefile,vim,uname的相关小知识，具体还需要多实验运行</div><div><br></div><wbr></div>]]></description>
	    <author><![CDATA[long1]]></author>
	    <comments>http://blog.163.com/lfw2565295@126/blog/static/122005162012318112822957</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/lfw2565295@126/blog/static/122005162012318112822957</guid>
    <pubDate>Wed, 18 Apr 2012 11:28:22 +0800</pubDate>
    <dcterms:modified>2012-04-18T11:28:22+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[又回校了]]></title>	
    <link>http://blog.163.com/lfw2565295@126/blog/static/12200516201231534543590</link>
    <description><![CDATA[<div>连续三周出去回来，本来简单的感冒，似乎越来越加剧了，我还算经常打篮球锻炼身体的人，哎，杯具<wbr><div>想想如今肾结石，脚扭伤，感冒一些列病，我也算“病怏怏”了。。</div><div><br></div><div>好了，说最近干了什么，首先是清明回家，这趟还挺好的，回家见见父母，上上坟，和亲戚交流交流，算是难得的节日。</div><div><br></div><div>接下来杭州腾讯笔试，周五晚上通知的，周六上午就要去浙大考试。。。考虑了半天，想出了一个方案，周六凌晨过去，反正时间安排也不好，随便去打打酱油。于是第二天3点半起床，刷新了早起新记录，然后黑乎乎的，没出租车，走到火车站。。。然后买了5点半的票，8点多到杭州，然后K21路1个小时的路程到浙大，真是累死，找到大学室友京龙百行，和百行一起参加了考试，考试内容反正计算机基础知识都涉及到，还有些想法题，做的感觉一般，就当一次经历了。</div><div><br></div><div>接下来是西安一个朋友内推的腾讯面试，想想去西安还是太麻烦了，最主要导师给我的任务是这周，不好意思推掉。这任务就是，老师病了，不方便带队参加省赛，希望我和另外两个老师带队，我有点经验，熟悉流程。于是周五下午1点半浩浩荡荡去浙大紫金港校区了，联系京龙，充饭卡，上次百行，他们均能得到些回扣（500吃掉400多，多余的给他们了），方便以后我来杭州请我吃饭。晚上住在外面小宾馆里，隔音效果很差。。。1点多了，楼梯上上下下声音很多，屋内老师打呼，楼上“爱爱”运动。。。这尼玛让我怎么睡。。。第二天还要很早起，去报道注册，发东西什么，忙到中午吃饭。腾讯杭州面试又是周五晚上才发过来，让我上午10点去瑞豪中心酒店面试。。我想如果不能改时间我就不去了，还好后来电话打过来改到下午2点，然后午饭后就匆匆赶过去，杭州的公交真是XXX，到那里1点，让我会议室里准备，其实我累的不行了，直接趴下睡了大半个小时，然后2点叫到我面试了，去1308房间，一同去的一名女生，结果一进去让我写程序，一个字符串的程序，不是一般的写个程序，而是需要算法，这个算法我脑子中没印象（后来问集训队员，尼玛是后缀数组，而且要纸上写。。）于是先写了个一般的，然后尝试写点优化的，没怎么写好。写程序时，旁边面试官问那个女生，不知道什么方向，那女生论文能力应该很强，说有写过一级论文，那个方向说的也头头是道，然后感觉问她的问题也挺简单的，让她写的程序更简单了。。她面试完了感觉挺好。然后轮到我了，首先程序没写好，其次问我会那些语言什么的，有没有写过汇编，比如如何写游戏外挂。。（明显不会），然后问上次笔试的加分题，然后问有没有玩过网游，熟悉图像处理什么的吗（当然玩过，图像处理什么的，果断不是我的方向，不会），然后问一根绳子烧完用10分钟，粗细不均匀，如何测试5分钟（尼玛脑筋急转弯题，貌似两头点着烧就可以了，当时一愣，不会），最后问网络编程里进程线程有什么区别（网络编程，没做过）。。整个下来，基本都是我不会的，想想也就这么杯具了吧，回去等消息，意思也是没什么消息了。</div><div><br></div><div>面试完，然后急匆匆的赶回浙大观战，还好队员给力，名次挺好的，最后本部3金3银2铜，行知2银1铜，都创了最好成绩。最后就是回校，晚上下雨，感觉冷了，又累，头也痛了，车上迷迷糊糊的睡回来，到10点半左右回到学校，感觉快趴了，买了个鸡蛋饼，回寝室了。</div><div><br></div><div>最后总结，最近看似很忙，但其实也不知道忙了什么，本来有准备面试复习什么的，但现在想想，操作系统，数据结构，算法，Linux，网络，c++,java程序，汇编，计算机组成，这么多知识，我完全没那么大能力能都精通，临时看的没什么效果，我也不应该对自己有那么高要求精通这么多，所以最近还是回到本行，研究生方向的论文继续做做，工作的事，以后再说吧，其次身体最要紧了，刚刚不久学校一个老师50岁左右上课前死了，让大家都很惊讶，为之可惜，我最近还是想修养修养吧，什么目标励志现在都是浮云，最后和中科大研究生朋友温鸿交流，觉得大公司这样的实习要求，还是很有商榷的，我们也不能算很差吧，工作啊，面试啊很多机遇很重要，如今还是做好本分，那么也就不想太多实习的事了，时间还有点，慢慢来了。</div></div>]]></description>
	    <author><![CDATA[long1]]></author>
	    <comments>http://blog.163.com/lfw2565295@126/blog/static/12200516201231534543590</comments>
    <slash:comments>2</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/lfw2565295@126/blog/static/12200516201231534543590</guid>
    <pubDate>Sun, 15 Apr 2012 16:13:49 +0800</pubDate>
    <dcterms:modified>2012-04-15T16:13:49+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[zz 榜样人物数理信息学院罗方炜：笃定坚守 淡定泰然]]></title>	
    <link>http://blog.163.com/lfw2565295@126/blog/static/122005162012313105654736</link>
    <description><![CDATA[<div><p style="color: rgb(51, 51, 51); font-family: Arial, 宋体; line-height: 19px; text-align: -webkit-auto; background-color: rgb(252, 252, 252); margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; text-indent: 28pt;"  >又上研究生网站了，呵呵，看看也挺好的！</p><p style="color: rgb(51, 51, 51); font-family: Arial, 宋体; line-height: 19px; text-align: -webkit-auto; background-color: rgb(252, 252, 252); margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; text-indent: 28pt;"  ><br></p><p style="color: rgb(51, 51, 51); font-family: Arial, 宋体; line-height: 19px; text-align: -webkit-auto; background-color: rgb(252, 252, 252); margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; text-indent: 28pt;"  ><a rel="nofollow" href="http://ygb.zjnu.edu.cn/show.aspx?id=1464&amp;cid=18"  >http://ygb.zjnu.edu.cn/show.aspx?id=1464&amp;cid=18</a> </p><p style="color: rgb(51, 51, 51); font-family: Arial, 宋体; line-height: 19px; text-align: -webkit-auto; background-color: rgb(252, 252, 252); margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; text-indent: 28pt;"  ><span style="font-size: 14pt; font-family: 仿宋_GB2312;"  ><br></span></p><p style="color: rgb(51, 51, 51); font-family: Arial, 宋体; line-height: 19px; text-align: -webkit-auto; background-color: rgb(252, 252, 252); margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; text-indent: 28pt;"  ><a rel="nofollow" href="http://ygb.zjnu.edu.cn/show.aspx?id=888&amp;cid=34"  >http://ygb.zjnu.edu.cn/show.aspx?id=888&amp;cid=34</a> </p><p style="color: rgb(51, 51, 51); font-family: Arial, 宋体; line-height: 19px; text-align: -webkit-auto; background-color: rgb(252, 252, 252); margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; text-indent: 28pt;"  ><br></p><p style="color: rgb(51, 51, 51); font-family: Arial, 宋体; line-height: 19px; text-align: -webkit-auto; background-color: rgb(252, 252, 252); margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; text-indent: 28pt;"  ><br></p><p style="color: rgb(51, 51, 51); font-family: Arial, 宋体; line-height: 19px; text-align: -webkit-auto; background-color: rgb(252, 252, 252); margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; text-indent: 28pt;"  ><span style="font-size: 14pt; font-family: 仿宋_GB2312;"  >罗方炜，浙江师范大学数理信息学院<span lang="EN-US"  >2010</span>级计算机软件与理论专业研究生。研究生期间，获得校优秀研究生干部，浙江师范大学“动感地带”奖学金等荣誉。现为所在专业班长。本科就读于浙江师范大学，期间曾获得校一等奖学金，校三好学生，校优秀研究生干部，校研究与创新奖，院优秀班干部，院科研之星等八项荣誉称号。</span></p><p align="center"  style="color: rgb(51, 51, 51); font-family: Arial, 宋体; line-height: 19px; background-color: rgb(252, 252, 252); margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; text-indent: 28pt; text-align: center;"  ><span lang="EN-US"  style="font-size: 14pt; font-family: 仿宋_GB2312;"  >&nbsp;</span></p><p style="color: rgb(51, 51, 51); font-family: Arial, 宋体; text-align: -webkit-auto; background-color: rgb(252, 252, 252); margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; word-break: break-all; text-indent: 28pt; line-height: 25pt;"  ><b><span style="font-size: 14pt; font-family: 仿宋_GB2312;"  >“只要我做了决定，就会一直走下去”<span lang="EN-US"  ></span></span></b></p><p align="center"  style="color: rgb(51, 51, 51); font-family: Arial, 宋体; line-height: 19px; background-color: rgb(252, 252, 252); margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; text-indent: 28pt; text-align: center;"  ><span lang="EN-US"  style="font-size: 14pt; font-family: 仿宋_GB2312;"  >&nbsp;</span></p><p style="color: rgb(51, 51, 51); font-family: Arial, 宋体; line-height: 19px; text-align: -webkit-auto; background-color: rgb(252, 252, 252); margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; text-indent: 28pt;"  ><span style="font-size: 14pt; font-family: 仿宋_GB2312;"  >说到<span lang="EN-US"  >2007</span>年<span lang="EN-US"  >5</span>月份第一次参加<span lang="EN-US"  >ACM</span>省赛，罗方炜的竞赛感触很多，“相比其他院校的优秀学子，我们感到了自身的不足。”尽管这次竞赛没有获奖，但罗方炜发现了存在的问题，回校后，他积极做好准备。他平时大部分时间都“泡”在机房里，钻心研发与设计。第一学年暑假他没有回家，而是选择留在学校参加暑期集训。所谓的集训是在电脑屏幕前，连续不间断地做五个小时的程序设计题。罗方炜说，一开始参加集训的人有<span lang="EN-US"  >20</span>余个，真正坚持到最后的人往往只有<span lang="EN-US"  >4-5</span>人。对于这种现象，他也表示理解。毕竟集训考验的不仅是专业知识，更是一种耐力与意志的磨砺。罗方炜每次都能坚持下来，说到个中缘由时，罗方炜说：“在不断训练中，我发现了很多瓶颈。我想突破瓶颈，提升自己。最初的确是因为兴趣选择了这个专业，而现在更多地是为了超越与挑战。在做题的最后会有排名，我每次都能衡量自己的名次。就像登山一样，既然我的目标是巅峰，只有登上顶峰，你才会发现景色尽收眼底，我是不会在半途中放弃的，只要我做了决定，就会一直走下去。”<span lang="EN-US"  ></span></span></p><p style="color: rgb(51, 51, 51); font-family: Arial, 宋体; line-height: 19px; text-align: -webkit-auto; background-color: rgb(252, 252, 252); margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; text-indent: 28pt;"  ><span style="font-size: 14pt; font-family: 仿宋_GB2312;"  >正是坚持不懈的顽强毅力，从20<span lang="EN-US"  >07</span>年到20<span lang="EN-US"  >11</span>年，罗方炜共参加过<span lang="EN-US"  >14</span>次<span lang="EN-US"  >ACM</span>国际大学生程序设计竞赛——最具影响力的大学生计算机竞赛。令人激动的是，<span lang="EN-US"  >2010</span>年<span lang="EN-US"  >10</span>月，罗方炜所在团队亚洲赛杭州站喜获金奖，并出线全球总决赛！<span lang="EN-US"  >2011</span>年，罗方炜带领小组成员参加了在美国佛罗里达州奥兰多<span lang="EN-US"  >(Orlando)</span>举办的全球总决赛，他感受到了世界顶尖高手的实力，开阔了视野。这不仅对于罗方炜、而且对于我们浙师大也是史上的大事件。<span lang="EN-US"  ></span></span></p><p align="center"  style="color: rgb(51, 51, 51); font-family: Arial, 宋体; line-height: 19px; background-color: rgb(252, 252, 252); margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; text-indent: 28pt; text-align: center;"  ><span lang="EN-US"  style="font-size: 14pt; font-family: 仿宋_GB2312;"  >&nbsp;</span></p><p style="color: rgb(51, 51, 51); font-family: Arial, 宋体; text-align: -webkit-auto; background-color: rgb(252, 252, 252); margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; word-break: break-all; text-indent: 28pt; line-height: 25pt;"  ><b><span style="font-size: 14pt; font-family: 仿宋_GB2312;"  >“以平常心来看待”<span lang="EN-US"  ></span></span></b></p><p align="center"  style="color: rgb(51, 51, 51); font-family: Arial, 宋体; line-height: 19px; background-color: rgb(252, 252, 252); margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; text-indent: 28pt; text-align: center;"  ><span lang="EN-US"  style="font-size: 14pt; font-family: 仿宋_GB2312;"  >&nbsp;</span></p><p style="color: rgb(51, 51, 51); font-family: Arial, 宋体; line-height: 19px; text-align: -webkit-auto; background-color: rgb(252, 252, 252); margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; text-indent: 28pt;"  ><span style="font-size: 14pt; font-family: 仿宋_GB2312;"  >随着参赛的实战经验的累积和对全局意识的把握，罗方炜成为了团队的组织者。此外，作为助理教练，他还负责组织集训，训练新队员。在得失取舍，分工定位，时间意识的操练中，他收获了很多。罗方炜说，之所以能取得这些竞技的荣誉，不完全归功于自己，团队作战尤为重要。<span lang="EN-US"  >ACM</span>属于一种现场竞赛，对团队的依赖性很大，取得的成绩是能及时看得到的。所以，比赛时三个成员做题的方向各有分工，每个人都有主攻的方向，这样组合起来才会各尽所长。<span lang="EN-US"  ></span></span></p><p style="color: rgb(51, 51, 51); font-family: Arial, 宋体; line-height: 19px; text-align: -webkit-auto; background-color: rgb(252, 252, 252); margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; text-indent: 28pt;"  ><span style="font-size: 14pt; font-family: 仿宋_GB2312;"  >在这个喧嚣与骚动的时代，保持一颗平常心是最重要的。罗方炜说，一个人的心态很重要。在参赛的时候，他都会以平常心来看待的，他会告诉自己，每次比赛都是一种对自己的检测，重要的是在比赛中能知道自己的哪些尚待提高的东西，这样自我暗示下来，他在比赛中会淡定自若，泰然处之，凡事尽力。而心理压力大的选手往往手忙脚乱。<span lang="EN-US"  ></span></span></p><p style="color: rgb(51, 51, 51); font-family: Arial, 宋体; line-height: 19px; text-align: -webkit-auto; background-color: rgb(252, 252, 252); margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; text-indent: 28pt;"  ><span style="font-size: 14pt; font-family: 仿宋_GB2312;"  >罗方炜酷爱运动，尤其喜爱打篮球。只要有闲暇，他都会在篮球场上一展身手。他也是以一颗平常心来看待生活的。生活的理想是为了理想的生活，这是人人渴求的。那么究竟什么是理想的生活呢？罗方炜在大三下学期曾作为交换生远赴土耳其城市花园大学留学一学期，这次经历给他感受最深的是那里的自由与闲适的氛围，他会经常和同学一起喝茶聊天。喝茶聊天中他们谈天说地，那是一种心境，也是一份自在。“闲看庭前花开花落，漫观天外云卷云舒”。宠辱不惊，去留无意间你会淡定从容积极地去面对人生，哪怕是几许失意。<span lang="EN-US"  ></span></span></p><p align="center"  style="color: rgb(51, 51, 51); font-family: Arial, 宋体; line-height: 19px; background-color: rgb(252, 252, 252); margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; text-indent: 28pt; text-align: center;"  ><span lang="EN-US"  style="font-size: 14pt; font-family: 仿宋_GB2312;"  >&nbsp;</span></p><p style="color: rgb(51, 51, 51); font-family: Arial, 宋体; text-align: -webkit-auto; background-color: rgb(252, 252, 252); margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; word-break: break-all; text-indent: 28pt; line-height: 25pt;"  ><b><span style="font-size: 14pt; font-family: 仿宋_GB2312;"  >“对自己有一个正确的定位”<span lang="EN-US"  ></span></span></b></p><p align="center"  style="color: rgb(51, 51, 51); font-family: Arial, 宋体; line-height: 19px; background-color: rgb(252, 252, 252); margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; text-indent: 28pt; text-align: center;"  ><span lang="EN-US"  style="font-size: 14pt; font-family: 仿宋_GB2312;"  >&nbsp;</span></p><p style="color: rgb(51, 51, 51); font-family: Arial, 宋体; line-height: 19px; text-align: -webkit-auto; background-color: rgb(252, 252, 252); margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; text-indent: 28pt;"  ><span style="font-size: 14pt; font-family: 仿宋_GB2312;"  >罗方炜是个稳重、勤勉的学生，在学习上“一步一个脚印”，走的很坚定，也很踏实。现在毕业论文正在准备的过程中，倾尽了大量心血。他喜欢动脑去思考、解决问题。除了<span lang="EN-US"  >ACM</span>竞赛，罗方炜也参加了一些数学建模的比赛。所谓数学建模，就是在三四天之内，通过对数学、物理、计算机、生物等学科的应用，解决一个实际问题，构建几种方案并以一篇论文的形式提交上去。通过众多的参赛，罗方炜掌握的是一种思维方式，而不是满足于攻克某一具体问题。罗方炜获得了“高教杯”省三等奖、美国数模二等奖的好成绩。他也做过些校级、院级课题与项目。<span lang="EN-US"  ></span></span></p><p style="color: rgb(51, 51, 51); font-family: Arial, 宋体; line-height: 19px; text-align: -webkit-auto; background-color: rgb(252, 252, 252); margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; text-indent: 28pt;"  ><span style="font-size: 14pt; font-family: 仿宋_GB2312;"  >说到工作的方向，罗方炜和能明确地说，未来的打算是最好能进大城市类似腾讯、阿里巴巴这样的<span lang="EN-US"  >IT</span>公司。他说，小公司的平台有很大局限，只有大公司的机制才更健全，学到的东西与提升的空间才会更大。当然，一开始大家都会从底层编码做起，他的理想职业是当一名好的计算机工程师。罗方炜对自己有一个准确的定位，“尽管在学校的表现还不错，但是就全国而已，我的成绩还是尚待提高的。”<span lang="EN-US"  ></span></span></p><p style="color: rgb(51, 51, 51); font-family: Arial, 宋体; line-height: 19px; text-align: -webkit-auto; background-color: rgb(252, 252, 252); margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; text-indent: 28pt;"  ><span style="font-size: 14pt; font-family: 仿宋_GB2312;"  >每个人都有属于自己的位置。一个人对自己的定位准确是很重要的。不要把自己定位太高而遮蔽双眼，也不要把自己定位太低而自暴自弃。<span lang="EN-US"  ></span></span></p><p style="color: rgb(51, 51, 51); font-family: Arial, 宋体; line-height: 19px; text-align: -webkit-auto; background-color: rgb(252, 252, 252); margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; text-indent: 28pt;"  ><span style="font-size: 14pt; font-family: 仿宋_GB2312;"  >态度决定一切。罗方炜的坚持、平常心与正确的定位决定了他今日的所作所为。汲取他人的养料浇灌自己的土壤，罗方炜的成长案例你得到收获了吗？</span></p><p style="color: rgb(51, 51, 51); font-family: Arial, 宋体; line-height: 19px; text-align: -webkit-auto; background-color: rgb(252, 252, 252); margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; text-indent: 28pt;"  ><span style="font-size: 14pt; font-family: 仿宋_GB2312;"  ></span>&nbsp;</p><span style="color: rgb(51, 51, 51); line-height: 19px; text-align: -webkit-auto; background-color: rgb(252, 252, 252); font-size: 14pt; font-family: 仿宋_GB2312;"  ><span lang="EN-US"  ><center><img title="zz 榜样人物数理信息学院罗方炜：笃定坚守 淡定泰然 - long1 - long1 vs longpo"  alt=""  src="http://ygb.zjnu.edu.cn/db/2012_04/12041310298596.jpg"  align="center"  style="border-style: initial; border-color: initial;"  ></center></span></span><span style="color: rgb(51, 51, 51); font-family: Arial, 宋体; line-height: 19px; text-align: -webkit-auto; background-color: rgb(252, 252, 252);"  ></span><p style="color: rgb(51, 51, 51); font-family: Arial, 宋体; line-height: 19px; text-align: -webkit-auto; background-color: rgb(252, 252, 252); margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; text-indent: 28pt;"  ><span lang="EN-US"  style="font-size: 14pt; font-family: 仿宋_GB2312;"  >&nbsp;</span></p><wbr></div>]]></description>
	    <author><![CDATA[long1]]></author>
	    <comments>http://blog.163.com/lfw2565295@126/blog/static/122005162012313105654736</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/lfw2565295@126/blog/static/122005162012313105654736</guid>
    <pubDate>Fri, 13 Apr 2012 10:56:54 +0800</pubDate>
    <dcterms:modified>2012-04-13T10:56:54+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[插入排序，希尔排序，堆排序，桶排序，外部排序]]></title>	
    <link>http://blog.163.com/lfw2565295@126/blog/static/1220051620123124277765</link>
    <description><![CDATA[<div><div>插入排序，希尔排序，堆排序，桶排序，外部排序</div><div><br></div><div>输入：</div><div>20</div><div>23 44 16 46 7 49 20 20 26 17 32 31 34 11 4 42 26 19 1 9</div><div>输出：</div><div>1 4 7 9 11 16 17 19 20 20 23 26 26 31 32 34 42 44 46 49&nbsp;</div><div><br></div><div>插入排序，最优可达O(n),一般O(n^2);</div><div>希尔排序，需要找增量序列，有点类似插入排序，可能有更好的增量，最坏O(n^2)</div><div>不好的情况：1 9 2 10 3 11 4 12 5 13 6 14 7 15 8 16,这样前几趟就是无用功</div><div>堆排序，构建二叉堆，每次将左右2个儿子中最大（最小）值与父亲比，保证父亲比儿子大（小），这样保证跟最大（小）</div><div>从0结点开始，左右儿子为0*2+1， 0*2+2</div><div>从1结点开始，左右儿子为1*2, 1*2+1</div><div>堆排序就是先构建好二叉堆，然后每次取堆顶元素，剩下的重构，为了节省空间，堆顶元素与a[j]交换，剩下j个元素重新构建</div><div><br></div><div>代码：</div><div>#include&lt;cstdio&gt;</div><div>#include&lt;cstring&gt;</div><div>#include&lt;iostream&gt;</div><div>#include&lt;cstdlib&gt;</div><div>using namespace std;</div><div>int a[1000];</div><div>void insertSort(int n,int *a){ //插入排序&nbsp;</div><div>&nbsp; &nbsp; for(int i,p=1; p&lt;n; p++){</div><div>&nbsp; &nbsp; &nbsp; &nbsp; int tmp=a[p];</div><div>&nbsp; &nbsp; &nbsp; &nbsp; for(i=p; i&gt;0 &amp;&amp; tmp&lt;a[i-1]; i--) a[i]=a[i-1];</div><div>&nbsp; &nbsp; &nbsp; &nbsp; a[i]=tmp;</div><div>&nbsp; &nbsp; }</div><div>}</div><div>void shellSort(int n,int *a){ //希尔排序&nbsp;</div><div>&nbsp; &nbsp; for(int gap=n/2; gap&gt;0; gap/=2){</div><div>&nbsp; &nbsp; &nbsp; &nbsp; for(int i=gap,j; i&lt;n; i++){</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int tmp=a[i];</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(j=i; j&gt;=gap &amp;&amp; tmp&lt;a[j-gap]; j-=gap) a[j]=a[j-gap];</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; a[j]=tmp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; }&nbsp;</div><div>}</div><div>inline int leftChild(int i){return i*2+1;}</div><div>void precDown(int *a,int i,int n){&nbsp;</div><div>&nbsp; &nbsp; int child,tmp=a[i];</div><div>&nbsp; &nbsp; for(; leftChild(i)&lt;n; i=child){</div><div>&nbsp; &nbsp; &nbsp; &nbsp; child=leftChild(i);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; if(child!=n-1 &amp;&amp; a[child]&lt;a[child+1]) child++; //找2个儿子中大的儿子</div><div>&nbsp; &nbsp; &nbsp; &nbsp; if(tmp&lt;a[child]) a[i]=a[child];</div><div>&nbsp; &nbsp; &nbsp; &nbsp; else break;</div><div>&nbsp; &nbsp; }</div><div>&nbsp; &nbsp; a[i]=tmp;</div><div>}</div><div>void heapSort(int n,int *a){ //堆排序&nbsp;</div><div>&nbsp; &nbsp; for(int i=n/2; i&gt;=0; i--) precDown(a,i,n); //buildHeap</div><div>&nbsp; &nbsp; for(int j=n-1; j&gt;=0; j--){</div><div>&nbsp; &nbsp; &nbsp; &nbsp; swap(a[0],a[j]); //deleteMax</div><div>&nbsp; &nbsp; &nbsp; &nbsp; precDown(a,0,j);</div><div>&nbsp; &nbsp; }</div><div>}</div><div>int main(){</div><div>&nbsp; &nbsp; freopen("a.in","r",stdin);</div><div>&nbsp; &nbsp; freopen("a.out","w",stdout);</div><div>&nbsp; &nbsp; int n;</div><div>&nbsp; &nbsp; scanf("%d",&amp;n);</div><div>&nbsp; &nbsp; for(int i=0; i&lt;n; i++) scanf("%d",&amp;a[i]);</div><div>&nbsp; &nbsp; //insertSort(n,a);</div><div>&nbsp; &nbsp; //shellSort(n,a);</div><div>&nbsp; &nbsp; heapSort(n,a);</div><div>&nbsp; &nbsp; for(int i=0; i&lt;n; i++) printf("%d ",a[i]);</div><div>}</div><div><br></div><div>桶排序，输入a1,a2...an,都小于m的时候，且都是正整数，则可以开大小为m的count数组，出现某个位置的数，count[a[i]]++</div><div>最后扫描count数组就可以了，用时O(n+m)，需要有预见性，知道规模 (<font color="#0000ff"  size="4"  ><b>其实就是 标记法 排序</b></font>)</div><div><br></div><div>外部排序，大部分内部排序算法都用到内存可<font color="#0000ff"  size="4"  ><b>直接寻址</b></font>的事实，但如果数据量大，放在磁带(磁盘),不可能直接寻址就失去了效率，磁带上是顺序访问，磁盘也有延迟</div><div>简单算法、多路合并、多相合并、替换选择</div><div><br></div><wbr></div>]]></description>
	    <author><![CDATA[long1]]></author>
	    <comments>http://blog.163.com/lfw2565295@126/blog/static/1220051620123124277765</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/lfw2565295@126/blog/static/1220051620123124277765</guid>
    <pubDate>Thu, 12 Apr 2012 16:27:07 +0800</pubDate>
    <dcterms:modified>2012-04-12T16:27:07+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[AVL树 类似平衡二叉树 SB树]]></title>	
    <link>http://blog.163.com/lfw2565295@126/blog/static/122005162012311103521985</link>
    <description><![CDATA[<div><h2 style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 6px; padding-left: 0px; font-size: 18px; line-height: 24px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(222, 223, 225); clear: both; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ><span>概述</span></h2><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　在计算机科学中，AVL树是最先发明的自平衡二叉查找树。AVL树得名于它的发明者 G.M. Adelson-Velsky 和 E.M. Landis，他们在 1962 年的论文 "An algorithm for the organization of information" 中发表了它。</span><div style="height: 30px; line-height: 30px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><h2 style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 6px; padding-left: 0px; font-size: 18px; line-height: 24px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(222, 223, 225); clear: both; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ><span data-edit-id="671745:671745:2"  style="font-size: 12px; float: right; display: block; margin-top: 10px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(51, 102, 204); font-weight: normal;"  ><a style="color: rgb(19, 110, 194); height: 15px; line-height: 16px; background-image: url(http://img.baidu.com/img/baike/bk-split-icons.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; display: block; width: 52px; padding-left: 18px; background-position: 0% -108px; background-repeat: no-repeat no-repeat; " class="nslog:1019" rel="nofollow" href="http://baike.baidu.com/view/671745.htm#"  >编辑本段</a></span><a style="text-decoration: underline; color: rgb(19, 110, 194); " name="2" rel="nofollow"  ></a><a style="text-decoration: underline; color: rgb(19, 110, 194); " name="sub671745_2" rel="nofollow"  ></a><span>AVL 节点数计算</span></h2><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　高度为 h 的 AVL 树, <b><font size="4"  color="#0000ff"  >节点数 N 最多2^h - 1</font></b>； <b><font color="#0000ff"  size="4"  >最少</font></b></span><b><font color="#0000ff"  size="4"  ><i style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >Nh</i><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >=&nbsp;</span><i style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >F【</i><i style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >h</i><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >+ 2】 - 1 (</span><i style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >F【</i><i style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >h</i></font></b><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  ><b><font color="#0000ff"  size="4"  >+ 2】是 Fibonacci polynomial 的第h+2个数)</font></b>。</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　最少节点数n 如以</span><a style="color: rgb(19, 110, 194); font-family: arial, &#23435;&#20307;, sans-serif; line-height: 24px; text-align: -webkit-auto; " target="_blank" rel="nofollow" href="http://baike.baidu.com/view/1703684.htm"  >费伯纳西数列</a><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >可以用数学归纳法证明：</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　即:</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　</span><i style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >N</i><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >0 = 0 (表示 AVL Tree 高度为0的节点总数)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　</span><i style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >N</i><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >1 = 1 (表示 AVL Tree 高度为1的节点总数)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　</span><i style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >N</i><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >2 = 2 (表示 AVL Tree 高度为2的节点总数)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><font size="4"  color="#0000ff"  ><b><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　</span><i style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >N</i><i style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >h</i><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >=&nbsp;</span><i style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >N【</i><i style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >h-</i><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >&nbsp;1】 +&nbsp;</span><i style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >N【</i><i style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >h</i><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >- 2】 + 1 (表示 AVL Tree 高度为h的节点总数)</span></b></font><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　换句话说，当节点数为N 时，高度h 最多为logN + 2。</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　节点的平衡因子是它的右子树的高度减去它的左子树的高度。带有平衡因子 1、0 或 -1 的节点被认为是平衡的。带有平衡因子 -2 或 2 的节点被认为是不平衡的，并需要重新平衡这个树。平衡因子可以直接存储在每个节点中，或从可能存储在节点中的子树高度计算出来。</span><div style="height: 30px; line-height: 30px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><h2 style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 6px; padding-left: 0px; font-size: 18px; line-height: 24px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(222, 223, 225); clear: both; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ><span data-edit-id="671745:671745:3"  style="font-size: 12px; float: right; display: block; margin-top: 10px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(51, 102, 204); font-weight: normal;"  ><a style="color: rgb(19, 110, 194); height: 15px; line-height: 16px; background-image: url(http://img.baidu.com/img/baike/bk-split-icons.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; display: block; width: 52px; padding-left: 18px; background-position: 0% -108px; background-repeat: no-repeat no-repeat; " class="nslog:1019" rel="nofollow" href="http://baike.baidu.com/view/671745.htm#"  >编辑本段</a></span><a style="text-decoration: underline; color: rgb(19, 110, 194); " name="3" rel="nofollow"  ></a><a style="text-decoration: underline; color: rgb(19, 110, 194); " name="sub671745_3" rel="nofollow"  ></a><span>操作</span></h2><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　AVL树的基本操作一般涉及运做同在不平衡的二叉查找树所运做的同样的算法。但是要进行预先或随后做一次或多次所谓的"AVL 旋转"。</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　假设由于在</span><a style="color: rgb(19, 110, 194); font-family: arial, &#23435;&#20307;, sans-serif; line-height: 24px; text-align: -webkit-auto; " target="_blank" rel="nofollow" href="http://baike.baidu.com/view/647462.htm"  >二叉排序树</a><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >上插入结点而失去平衡的最小子树根结点的指针为a(即a是离插入点最近，且平衡因子</span><a style="color: rgb(19, 110, 194); font-family: arial, &#23435;&#20307;, sans-serif; line-height: 24px; text-align: -webkit-auto; " target="_blank" rel="nofollow" href="http://baike.baidu.com/view/220956.htm"  >绝对值</a><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >超过1的祖先结点)，则失去平衡后进行进行的规律可归纳为下列四种情况：</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　<b><font color="#0000ff"  >单向右旋平衡处理RR：由于在*a的右子树根结点的右子树上插入结点，*a的平衡因子由1增至2，致使以*a为根的子树失去平衡，则需进行一次右旋转操作；</font></b></span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  ><b><font color="#0000ff"  >　　单向左旋平衡处理LL：由于在*a的左子树根结点的左子树上插入结点，*a的平衡因子由-1变为-2，致使以*a为根的子树失去平衡，则需进行一次左旋转操作；</font></b></span><div><div style="text-align: -webkit-auto;"  ><font color="#0000ff"  face="arial, 宋体, sans-serif"  ><b>一字型旋转</b></font></div><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  ><b><font color="#0000ff"  >　　双向旋转（先左后右）平衡处理LR：由于在*a的左子树根结点的右子树上插入结点，*a的平衡因子由1增至2，致使以*a为根的子树失去平衡，则需进行两次旋转（先左旋后右旋）操作。</font></b></span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  ><b><font color="#0000ff"  >　　双向旋转（先右后左）平衡处理RL：由于在*a的右子树根结点的左子树上插入结点，*a的平衡因子由-1变为-2，致使以*a为根的子树失去平衡，则需进行两次旋转（先右旋后左旋）操作。</font></b></span></div><div><div style="text-align: -webkit-auto;"  ><font color="#0000ff"  face="arial, 宋体, sans-serif"  ><b>之字型旋转</b></font></div><h3 style="margin-top: 15px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 16px; font-family: Arial; line-height: 22px; clear: both; text-align: -webkit-auto;"  ><a style="text-decoration: underline; color: rgb(19, 110, 194); " name="3_1" rel="nofollow"  ></a><a style="text-decoration: underline; color: rgb(19, 110, 194); " name="sub671745_3_1" rel="nofollow"  ></a><span>插入</span></h3><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　向AVL树插入可以通过如同它是未平衡的二叉查找树一样把给定的值插入树中，接着自底向上向根节点折回，于在插入期间成为不平衡的所有节点上进行旋转来完成。因为折回到根节点的路途上最多有 1.5 乘 log n 个节点，而每次 AVL 旋转都耗费恒定的时间，插入处理在整体上耗费 O(log n) 时间。　在平衡的的二叉排序树Balanced BST上插入一个新的数据元素e的递归算法可描述如下：　若BBST为空树，则插入一个数据元素为e的新结点作为BBST的根结点，树的深度增1； 若e的关键字和BBST的根结点的关键字相等，则不进行； 若e的关键字小于BBST的根结点的关键字，而且在BBST的左子树中不存在和e有相同关键字的结点，则将e插入在BBST的左子树上，并且当插入之后的左子树深度增加(+1)时，分别就下列不同情况处理之： BBST的根结点的平衡因子为-1(右子树的深度大于左子树的深度，则将根结点的平衡因子更改为0，BBST的深度不变； BBST的根结点的平衡因子为0（左、右子树的深度相等）：则将根结点的平衡因子更改为1，BBST的深度增1； BBST的根结点的平衡因子为1（左子树的深度大于右子树的深度）：则若BBST的左子树根结点的平衡因子为1：则需进行单向右旋平衡处理，并且在右旋处理之后，将根结点和其右子树根结点的平衡因子更改为0，树的深度不变； 若e的关键字大于BBST的根结点的关键字，而且在BBST的右子树中不存在和e有相同关键字的结点，则将e插入在BBST的右子树上，并且当插入之后的右子树深度增加(+1)时，分别就不同情况处理之。</span><h3 style="margin-top: 15px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 16px; font-family: Arial; line-height: 22px; clear: both; text-align: -webkit-auto;"  ><a style="text-decoration: underline; color: rgb(19, 110, 194); " name="3_2" rel="nofollow"  ></a><a style="text-decoration: underline; color: rgb(19, 110, 194); " name="sub671745_3_2" rel="nofollow"  ></a><span>删除</span></h3><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　从AVL树中删除可以通过把要删除的节点向下旋转成一个</span><a style="color: rgb(19, 110, 194); font-family: arial, &#23435;&#20307;, sans-serif; line-height: 24px; text-align: -webkit-auto; " target="_blank" rel="nofollow" href="http://baike.baidu.com/view/544292.htm"  >叶子节点</a><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >，接着直接剪除这个叶子节点来完成。因为在旋转成叶子节点期间最多有 log n个节点被旋转，而每次 AVL 旋转耗费恒定的时间，删除处理在整体上耗费 O(log n) 时间。</span><h3 style="margin-top: 15px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 16px; font-family: Arial; line-height: 22px; clear: both; text-align: -webkit-auto;"  ><a style="text-decoration: underline; color: rgb(19, 110, 194); " name="3_3" rel="nofollow"  ></a><a style="text-decoration: underline; color: rgb(19, 110, 194); " name="sub671745_3_3" rel="nofollow"  ></a><span>查找</span></h3><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　在AVL树中查找同在一般BST完全一样的进行，所以耗费 O(log n) 时间，因为AVL树总是保持平衡的。不需要特殊的准备，树的结构不会由于查询而改变。(这是与伸展树查找相对立的，它会因为查找而变更树结构。)</span><div style="height: 30px; line-height: 30px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><h2 style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 6px; padding-left: 0px; font-size: 18px; line-height: 24px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(222, 223, 225); clear: both; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ><span data-edit-id="671745:671745:4"  style="font-size: 12px; float: right; display: block; margin-top: 10px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(51, 102, 204); font-weight: normal;"  ><a style="color: rgb(19, 110, 194); height: 15px; line-height: 16px; background-image: url(http://img.baidu.com/img/baike/bk-split-icons.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; display: block; width: 52px; padding-left: 18px; background-position: 0% -108px; background-repeat: no-repeat no-repeat; " class="nslog:1019" rel="nofollow" href="http://baike.baidu.com/view/671745.htm#"  >编辑本段</a></span><a style="text-decoration: underline; color: rgb(19, 110, 194); " name="4" rel="nofollow"  ></a><a style="text-decoration: underline; color: rgb(19, 110, 194); " name="sub671745_4" rel="nofollow"  ></a><span>参考实现</span></h2><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　给出一个操作AVLTREE的完整程序 大部分由Peter Brass编写　#include &lt;iostream.h&gt;　#include &lt;math.h&gt;　#include &lt;stdlib.h&gt;　//建立一个整数类型　typedef struct obj_n_t　{　int obj_key;　} obj_node_t;　//建立树结点的基本机构　typedef struct tree_n_t {　int key;　struct tree_n_t *left,*right;　int height;　} tree_node_t;　//建立堆栈　#define MAXSIZE 512　tree_node_t *stack[MAXSIZE]; //warning!the tree can contain 256 leaves at most!　int i=0; //堆栈计数器　//堆栈清空　void stack_clear()　{　while(i!=0)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　stack[i-1]=NULL;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　i--;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　//堆栈为空</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　int stack_empty()</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　return(i==0);</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　//入栈函数</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　int push(tree_node_t *node)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　if(i&lt;MAXSIZE)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　stack[i++]=node;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　return(0);</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　else</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　return(-1);</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　//出栈函数</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　tree_node_t *pop()</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　if(i&gt;0)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　return(stack[--i]);</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　else</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　return(0);</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　//建立get_node函数，用于</span><a style="color: rgb(19, 110, 194); font-family: arial, &#23435;&#20307;, sans-serif; line-height: 24px; text-align: -webkit-auto; " target="_blank" rel="nofollow" href="http://baike.baidu.com/view/3687138.htm"  >动态分配内存</a><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >空间</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　tree_node_t *get_node()</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　tree_node_t *tmp;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　tmp=(tree_node_t *)malloc(sizeof(tree_node_t));</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　return(tmp);</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　//建立return_node函数，用于释放内存</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　void return_node(tree_node_t *free_node)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　free(free_node);</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　//建立左旋转函数</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　void left_rotation(tree_node_t *node)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　tree_node_t *tmp;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　int tmp_key;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　tmp=node-&gt;left;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　tmp_key=node-&gt;key;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　node-&gt;left=node-&gt;right;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　node-&gt;key=node-&gt;right-&gt;key;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　node-&gt;right=node-&gt;left-&gt;right;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　node-&gt;left-&gt;right=node-&gt;left-&gt;left;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　node-&gt;left-&gt;left=tmp;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　node-&gt;left-&gt;key=tmp_key;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　//建立右旋转函数</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　void right_rotation(tree_node_t *node)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　tree_node_t *tmp;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　int tmp_key;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　tmp=node-&gt;right;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　tmp_key=node-&gt;key;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　node-&gt;right=node-&gt;left;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　node-&gt;key=node-&gt;left-&gt;key;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　node-&gt;left=node-&gt;right-&gt;left;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　node-&gt;right-&gt;left=node-&gt;right-&gt;right;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　node-&gt;right-&gt;right=tmp;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　node-&gt;right-&gt;key=tmp_key;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　int rebalance(tree_node_t *node)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　int finished=0;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　while(!stack_empty()&amp;&amp;!finished)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　int tmp_height,old_height;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　node=pop(); //back to the root along the search path</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　old_height=node-&gt;height;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　if(node-&gt;left-&gt;height-node-&gt;right-&gt;height==2)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　if(node-&gt;left-&gt;left-&gt;height-node-&gt;right-&gt;height==1)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　right_rotation(node);</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　node-&gt;right-&gt;height=node-&gt;right-&gt;left-&gt;height+1;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　node-&gt;height=node-&gt;right-&gt;height+1;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　else</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　left_rotation(node-&gt;left);</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　right_rotation(node);</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　tmp_height=node-&gt;left-&gt;left-&gt;height;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　node-&gt;left-&gt;height=tmp_height+1;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　node-&gt;right-&gt;height=tmp_height+1;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　node-&gt;height=tmp_height+2;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　else if(node-&gt;left-&gt;height-node-&gt;right-&gt;height==-2)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　if(node-&gt;right-&gt;right-&gt;height-node-&gt;left-&gt;height==1)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　left_rotation(node);</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　node-&gt;left-&gt;height=node-&gt;left-&gt;right-&gt;height+1;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　node-&gt;height=node-&gt;left-&gt;height+1;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　else</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　right_rotation(node-&gt;right);</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　left_rotation(node);</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　tmp_height=node-&gt;right-&gt;right-&gt;height;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　node-&gt;left-&gt;height=tmp_height+1;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　node-&gt;right-&gt;height=tmp_height+1;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　node-&gt;height=tmp_height+2;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　else</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　if(node-&gt;left-&gt;height&gt;node-&gt;right-&gt;height)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　node-&gt;height=node-&gt;left-&gt;height+1;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　else</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　node-&gt;height=node-&gt;right-&gt;height+1;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　if(node-&gt;height==old_height)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　finished=1;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　stack_clear();</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　return(0);</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　//建立creat_tree函数，用于建立一颗空树</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　tree_node_t *creat_tree()</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　tree_node_t *root;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　root=get_node();</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　root-&gt;left=root-&gt;right=NULL;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　root-&gt;height=0;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　return(root); //build up an empty tree.the first insert bases on the empty tree.</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　//建立</span><a style="color: rgb(19, 110, 194); font-family: arial, &#23435;&#20307;, sans-serif; line-height: 24px; text-align: -webkit-auto; " target="_blank" rel="nofollow" href="http://baike.baidu.com/view/2803763.htm"  >find函数</a><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >，用于查找一个对象</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　obj_node_t *find(tree_node_t *tree,int query_key)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　tree_node_t *tmp;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　if(tree-&gt;left==NULL)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　return(NULL);</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　else</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　tmp=tree;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　while(tmp-&gt;right!=NULL)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　if(query_key&lt;tmp-&gt;key)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　tmp=tmp-&gt;left;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　else</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　tmp=tmp-&gt;right;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　if(tmp-&gt;key==query_key)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　return((obj_node_t*)tmp-&gt;left);</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　else</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　return(NULL);</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　//建立插入函数</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　int insert(tree_node_t *tree,obj_node_t *new_obj)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　tree_node_t *tmp;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　int query_key,new_key;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　query_key=new_key=new_obj-&gt;obj_key;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　if(tree-&gt;left==NULL)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　tree-&gt;left=(tree_node_t *)new_obj;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　tree-&gt;key=new_key;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　tree-&gt;height=0;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　tree-&gt;right=NULL;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　else</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　stack_clear();</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　tmp=tree;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　while(tmp-&gt;right!=NULL)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　//use stack to remember the path from root to the position at which the new object should be inserted.</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　//then after inserting,we can rebalance from the parrent node of the leaf which pointing to new object to the root node.</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　push(tmp);</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　if(query_key&lt;tmp-&gt;key)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　tmp=tmp-&gt;left;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　else</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　tmp=tmp-&gt;right;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　if(tmp-&gt;key==query_key)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　return(-1);</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　else</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　tree_node_t *old_leaf,*new_leaf;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　//It must allocate 2 node space in memory.</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　//One for the new one,another for the old one.</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　//the previous node becomes the parrent of the new node.</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　//when we delete a leaf,it will free two node memory spaces as well.</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　old_leaf=get_node();</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　old_leaf-&gt;left=tmp-&gt;left;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　old_leaf-&gt;key=tmp-&gt;key;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　old_leaf-&gt;right=NULL;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　old_leaf-&gt;height=0;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　new_leaf=get_node();</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　new_leaf-&gt;left=(tree_node_t *)new_obj;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　new_leaf-&gt;key=new_key;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　new_leaf-&gt;right=NULL;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　new_leaf-&gt;height=0;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　if(tmp-&gt;key&lt;new_key)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　tmp-&gt;left=old_leaf;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　tmp-&gt;right=new_leaf;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　tmp-&gt;key=new_key;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　else</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　tmp-&gt;left=new_leaf;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　tmp-&gt;right=old_leaf;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　tmp-&gt;height=1;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　rebalance(tmp);</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　return(0);</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　//建立删除函数</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　int del(tree_node_t *tree,int key)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　tree_node_t *tmp,*upper,*other;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　if(tree-&gt;left==NULL)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　return(-1);</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　else if(tree-&gt;right==NULL)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　if(tree-&gt;key==key)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　tree-&gt;left=NULL;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　return(0);</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　else</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　return(-1);</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　else</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　tmp=tree;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　stack_clear();</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　while(tmp-&gt;right!=NULL)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　upper=tmp;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　push(upper);</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　if(key&lt;tmp-&gt;key)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　tmp=upper-&gt;left;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　other=upper-&gt;right;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　else</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　tmp=upper-&gt;right;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　other=upper-&gt;left;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　if(tmp-&gt;key!=key)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　return(-1);</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　else</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　upper-&gt;key=other-&gt;key;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　upper-&gt;left=other-&gt;left;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　upper-&gt;right=other-&gt;right;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　upper-&gt;height=upper-&gt;height-1;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　return_node(tmp);</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　return_node(other);</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　rebalance(pop());</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　//here must pop,then rebalance can run from the parrent of upper,because upper has become a leaf.</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　return(0);</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　//建立测试遍历函数</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　int travel(tree_node_t *tree)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　stack_clear();</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　if(tree-&gt;left==NULL)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　push(tree);</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　else if(tree-&gt;left!=NULL)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　int m=0;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　push(tree);</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　while(i!=m)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　if(stack[m]-&gt;left!=NULL &amp;&amp; stack[m]-&gt;right!=NULL)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　push(stack[m]-&gt;left);</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　push(stack[m]-&gt;right);</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　m++;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　return(0);</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　//建立测试函数</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　int test_structure(tree_node_t *tree)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　travel(tree);</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　int state=-1;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　while(!stack_empty())</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　--i;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　if(stack</span><i style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >-&gt;</i><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >right==NULL &amp;&amp; stack-&gt;height==0) //this statement is leaf,but also contains an empty tree</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　state=0;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　else if(stack-&gt;left!=NULL &amp;&amp; stack-&gt;right!=NULL)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　if(abs(stack-&gt;height-stack-&gt;height)&lt;=1)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　state=0;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　else</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　state=-1;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　stack_clear();</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　stack_clear();</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　return(state);</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　//建立remove_tree函数</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　int remove_tree(tree_node_t *tree)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　travel(tree);</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　if(stack_empty())</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　return(-1);</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　else</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　while(!stack_empty())</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　return_node(pop());</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　return(0);</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　void main()</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　tree_node_t *atree=NULL;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　obj_node_t obj[256],*f; //MAXSIZE=n(number of leaf)+(n-1) number of node</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　int n,j=0;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　cout&lt;&lt;"Now Let's start this program! There is no tree in memory.\n";</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　int item;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　while(item!=0)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　cout&lt;&lt;"\nRoot address = "&lt;&lt;atree&lt;&lt;"\n";</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　cout&lt;&lt;"\n1.Create a tree\n";</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　cout&lt;&lt;"\n2.Insert a int type object\n";</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　cout&lt;&lt;"\n3.Test the structure of the tree\n";</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　cout&lt;&lt;"\n4.Find a object\n";</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　cout&lt;&lt;"\n6.Delete a object\n";</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　cout&lt;&lt;"\n7.Remove the Tree\n";</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　cout&lt;&lt;"\n0.Exit\n";</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　cout&lt;&lt;"\nPlease select:";</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　cin&gt;&gt;item;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　cout&lt;&lt;"\n\n\n";</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　switch(item)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　case 1:</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　atree=creat_tree();</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　cout&lt;&lt;"\nA new empty tree has been built up!\n";</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　break;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　case 2:</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　if(atree!=NULL)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　while(n!=3458)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　cout&lt;&lt;"Please insert a new object.\nOnly one object every time(3458 is an end code) : ";</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　cin&gt;&gt;n;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　if(n!=3458)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　obj[j].obj_key=n;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　if(insert(atree,&amp;obj[j])==0)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　j++;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　cout&lt;&lt;"Integer "&lt;&lt;n&lt;&lt;" has been input!\n\n";</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　else</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　cout&lt;&lt;"\n\nInsert failed!\n\n";</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　else</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　cout&lt;&lt;"\n\nNo tree in memory,insert Fail!\n\n";</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　break;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　case 3:</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　if(atree!=NULL)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　n=test_structure(atree);</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　if(n==-1)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　cout&lt;&lt;"\n\nIt's not a correct AVL tree.\n\n";</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　if(n==0)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　cout&lt;&lt;"\n\nIt's a AVL tree\n\n";</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　else</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　cout&lt;&lt;"\n\nNo tree in memory,Test Fail!\n\n";</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　break;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　case 4:</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　if(atree!=NULL)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　cout&lt;&lt;"\n\nWhat do you want to find? : ";</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　cin&gt;&gt;n;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　f=find(atree,n);</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　if(f==NULL)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　cout&lt;&lt;"\n\nSorry,"&lt;&lt;n&lt;&lt;" can't be found!\n\n";</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　else</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　cout&lt;&lt;"\n\nObject "&lt;&lt;f-&gt;obj_key&lt;&lt;" has been found!\n\n";</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　else</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　cout&lt;&lt;"\n\nNo tree in memory,Find Fail!\n\n";</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　break;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　case 5:</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　if(atree!=NULL)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　travel(atree);</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　for(int count=0;count&lt;i;count++)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　cout&lt;&lt;" "&lt;&lt;stack[count]-&gt;key&lt;&lt;",";</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　else</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　cout&lt;&lt;"\n\nNo tree in memory,Travel Fail!\n\n";</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　break;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　case 6:</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　if(atree!=NULL)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　cout&lt;&lt;"\n\nWhich object do you want to delete?\n\n";</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　cin&gt;&gt;n;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　if(del(atree,n)==0)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　cout&lt;&lt;"\n\n"&lt;&lt;n&lt;&lt;" has been deleted!\n\n";</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　else</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　cout&lt;&lt;"\n\nNo this object\n\n";</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　else</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　cout&lt;&lt;"\n\nNo tree in memory,Delete Fail!\n\n";</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　break;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　case 7:</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　if(atree!=NULL)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　remove_tree(atree);</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　cout&lt;&lt;"\n\nThe Tree has been removed!\n\n";</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　atree=NULL;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　else</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　cout&lt;&lt;"\n\nNo tree in memory,Removing Fail!\n\n";</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　default:</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　cout&lt;&lt;"\n\nNo this operation!\n\n";</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　n=0;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><wbr><br></div></div>]]></description>
	    <author><![CDATA[long1]]></author>
	    <comments>http://blog.163.com/lfw2565295@126/blog/static/122005162012311103521985</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/lfw2565295@126/blog/static/122005162012311103521985</guid>
    <pubDate>Wed, 11 Apr 2012 22:35:21 +0800</pubDate>
    <dcterms:modified>2012-04-11T22:39:24+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[SQL查询前10条记录（SqlServer/mysql/oracle）[语法分析] （转)]]></title>	
    <link>http://blog.163.com/lfw2565295@126/blog/static/1220051620123101617148</link>
    <description><![CDATA[<div><span style="color: rgb(138, 134, 121); font-family: Arial, Helvetica, simsun, u5b8bu4f53; font-size: 12px; line-height: normal;"  ><h3 style="overflow-x: hidden; overflow-y: hidden; text-align: left; white-space: normal; word-wrap: break-word; word-break: break-all; font-size: 14px; margin-top: 30px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 24px;"  ><span style="font-size: 20px; font-family: 微软雅黑, 黑体, Arial, Helvetica, sans-serif;"  >SQL查询前10条记录（SqlServer/mysql/oracle）[语法分析] （转)</span>&nbsp;</h3></span><span style="color: rgb(138, 134, 121); font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px;"  ><p style="line-height: 25px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><strong style="line-height: 25px;"  >Sql Server :</strong></p><p style="line-height: 25px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  >Sql代码</p><div style="line-height: 25px;"  ><ol style="line-height: 25px; margin-top: 5px; margin-right: 0px; margin-bottom: 5px; margin-left: 40px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><li style="line-height: 25px;"  ><span style="line-height: 25px;"  ><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >select</font></strong></span><span style="line-height: 25px;"  >&nbsp;</span><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >top</font></strong></span><span style="line-height: 25px;"  >&nbsp;X *&nbsp;</span><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >from</font></strong></span><span style="line-height: 25px;"  >&nbsp;table_name&nbsp;</span><span style="line-height: 25px;"  ><font color="#008200"  style="line-height: 25px;"  >--查询前X条记录，可以改成需要的数字。</font></span><span style="line-height: 25px;"  ></span></span></li><li style="line-height: 25px;"  ><span style="line-height: 25px;"  ><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >select</font></strong></span><span style="line-height: 25px;"  >&nbsp;</span><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >top</font></strong></span><span style="line-height: 25px;"  >&nbsp;n *&nbsp;</span><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >from</font></strong></span><span style="line-height: 25px;"  >&nbsp;(</span><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >select</font></strong></span><span style="line-height: 25px;"  >&nbsp;</span><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >top</font></strong></span><span style="line-height: 25px;"  >&nbsp;m *&nbsp;</span><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >from</font></strong></span><span style="line-height: 25px;"  >&nbsp;table_name&nbsp;</span><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >order</font></strong></span><span style="line-height: 25px;"  >&nbsp;</span><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >by</font></strong></span><span style="line-height: 25px;"  >&nbsp;column_name ) a&nbsp;</span><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >order</font></strong></span><span style="line-height: 25px;"  >&nbsp;</span><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >by</font></strong></span><span style="line-height: 25px;"  >&nbsp;column_name</span><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >desc</font></strong></span><span style="line-height: 25px;"  >&nbsp;</span><span style="line-height: 25px;"  ><font color="#008200"  style="line-height: 25px;"  >--查询第N到M条记录。常用的分页也是这种方式。</font></span><span style="line-height: 25px;"  ></span></span></li><li style="line-height: 25px;"  ><span style="line-height: 25px;"  >例如常用的分页方式：</span></li><li style="line-height: 25px;"  ><span style="line-height: 25px;"  ><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >declare</font></strong></span><span style="line-height: 25px;"  >&nbsp;@page&nbsp;</span><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >int</font></strong></span><span style="line-height: 25px;"  ></span></span></li><li style="line-height: 25px;"  ><span style="line-height: 25px;"  ><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >declare</font></strong></span><span style="line-height: 25px;"  >&nbsp;@row&nbsp;</span><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >int</font></strong></span><span style="line-height: 25px;"  ></span></span></li><li style="line-height: 25px;"  ><span style="line-height: 25px;"  ><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >set</font></strong></span><span style="line-height: 25px;"  >&nbsp;@page=2&nbsp;</span><span style="line-height: 25px;"  ><font color="#008200"  style="line-height: 25px;"  >--页数</font></span><span style="line-height: 25px;"  ></span></span></li><li style="line-height: 25px;"  ><span style="line-height: 25px;"  ><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >set</font></strong></span><span style="line-height: 25px;"  >&nbsp;@row=3&nbsp;</span><span style="line-height: 25px;"  ><font color="#008200"  style="line-height: 25px;"  >--每页展示行数</font></span><span style="line-height: 25px;"  ></span></span></li><li style="line-height: 25px;"  ><span style="line-height: 25px;"  ><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >select</font></strong></span><span style="line-height: 25px;"  >&nbsp;</span><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >top</font></strong></span><span style="line-height: 25px;"  >&nbsp;(@row) *&nbsp;</span><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >from</font></strong></span><span style="line-height: 25px;"  >&nbsp;(</span><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >select</font></strong></span><span style="line-height: 25px;"  >&nbsp;</span><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >top</font></strong></span><span style="line-height: 25px;"  >&nbsp;(@row*@page) *&nbsp;</span><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >from</font></strong></span><span style="line-height: 25px;"  >&nbsp;table_name&nbsp;</span><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >order</font></strong></span><span style="line-height: 25px;"  >&nbsp;</span><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >by</font></strong></span><span style="line-height: 25px;"  >&nbsp;id ) a&nbsp;</span><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >order</font></strong></span><span style="line-height: 25px;"  >&nbsp;</span><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >by</font></strong></span><span style="line-height: 25px;"  >&nbsp;id</span><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >desc</font></strong></span><span style="line-height: 25px;"  >&nbsp;</span><span style="line-height: 25px;"  ><font color="#008200"  style="line-height: 25px;"  >--最基本的分页方式，改变@row和@page达到分页效果</font></span><span style="line-height: 25px;"  ></span></span></li></ol></div><p style="line-height: 25px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ></p><p style="line-height: 25px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  >&nbsp;</p><p style="line-height: 25px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><strong style="line-height: 25px;"  >MYSQL查询前10条的方法(limit参数的第一个参数n（<span style="line-height: 25px; background-color: rgb(255, 255, 255);"  ><span style="line-height: 25px; color: rgb(255, 0, 0);"  >如下面的0或1）表示前n条记录是不在选择范围内，相当于hibernate的setFirstResult的参数加一；第二个参数表示要选择的记录条数，相当于hibernate的setMaxResult的参数</span></span>)：</strong></p><div style="line-height: 25px;"  ><div style="line-height: 25px;"  ><div style="line-height: 25px;"  >Sql代码</div></div><ol style="line-height: 25px; margin-top: 5px; margin-right: 0px; margin-bottom: 5px; margin-left: 40px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><li style="line-height: 25px;"  ><span style="line-height: 25px;"  ><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >select</font></strong></span><span style="line-height: 25px;"  >&nbsp;*&nbsp;</span><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >from</font></strong></span><span style="line-height: 25px;"  >&nbsp;table_name limit 0,10&nbsp;</span><span style="line-height: 25px;"  ><font color="#008200"  style="line-height: 25px;"  >--通常0是可以省略的，直接写成 limit 10。0代表从第0条记录后面开始，也就是从第一条开始</font></span><span style="line-height: 25px;"  ></span></span></li><li style="line-height: 25px;"  ><span style="line-height: 25px;"  ><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >select</font></strong></span><span style="line-height: 25px;"  >&nbsp;*&nbsp;</span><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >from</font></strong></span><span style="line-height: 25px;"  >&nbsp;table_name limit 1,10&nbsp;</span><span style="line-height: 25px;"  ><font color="#008200"  style="line-height: 25px;"  >--则为从第一条后面的记录开始展示，也就是说从第二条开始。</font></span><span style="line-height: 25px;"  ></span></span></li></ol></div><p style="line-height: 25px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><span style="line-height: 25px; color: rgb(255, 0, 0);"  >MySQL查询前5条方法(</span><span style="line-height: 25px; color: rgb(255, 0, 0);"  >假设一个表为users表，这里作为子查询时要加入别名不然会出错，还有一点要注意的是order by在limit前面，不然还没出结果前就说要前几条，怎么搞嘛，所以limit要放最后。)：</span></p><div style="line-height: 25px;"  ><div style="line-height: 25px;"  ><div style="line-height: 25px;"  >Sql代码&nbsp;</div></div><ol style="line-height: 25px; margin-top: 5px; margin-right: 0px; margin-bottom: 5px; margin-left: 40px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><li style="line-height: 25px;"  ><span style="line-height: 25px;"  ><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >select</font></strong></span><span style="line-height: 25px;"  >&nbsp;*&nbsp;</span><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >from</font></strong></span><span style="line-height: 25px;"  >&nbsp;(</span><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >select</font></strong></span><span style="line-height: 25px;"  >&nbsp;*&nbsp;</span><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >from</font></strong></span><span style="line-height: 25px;"  >&nbsp;users&nbsp;</span><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >order</font></strong></span><span style="line-height: 25px;"  >&nbsp;</span><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >by</font></strong></span><span style="line-height: 25px;"  >&nbsp;id limit 0 , 10) partOfUsers&nbsp;</span><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >order</font></strong></span><span style="line-height: 25px;"  >&nbsp;</span><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >by</font></strong></span><span style="line-height: 25px;"  >&nbsp;id&nbsp;</span><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >desc</font></strong></span><span style="line-height: 25px;"  >&nbsp;limit 0 , 5;</span></span></li></ol></div><p style="line-height: 25px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ></p><p style="line-height: 25px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ></p><p style="line-height: 25px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><font color="#333399"  style="line-height: 25px; background-color: rgb(0, 128, 0);"  ><strong style="line-height: 25px;"  >ORACLE查询前十条的方法：</strong></font></p><div style="line-height: 25px;"  ><div style="line-height: 25px;"  ><div style="line-height: 25px;"  >Sql代码</div></div><ol style="line-height: 25px; margin-top: 5px; margin-right: 0px; margin-bottom: 5px; margin-left: 40px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><li style="line-height: 25px;"  ><span style="line-height: 25px;"  ><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >select</font></strong></span><span style="line-height: 25px;"  >&nbsp;*&nbsp;</span><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >from</font></strong></span><span style="line-height: 25px;"  >&nbsp;table_name&nbsp;</span><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >where</font></strong></span><span style="line-height: 25px;"  >&nbsp;rownum&lt;X&nbsp;</span><span style="line-height: 25px;"  ><font color="#008200"  style="line-height: 25px;"  >--X为前多少条记录</font></span><span style="line-height: 25px;"  ></span></span></li><li style="line-height: 25px;"  ><span style="line-height: 25px;"  ><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >select</font></strong></span><span style="line-height: 25px;"  >&nbsp;*&nbsp;</span><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >from</font></strong></span><span style="line-height: 25px;"  >&nbsp;(</span><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >select</font></strong></span><span style="line-height: 25px;"  >&nbsp;a.*,a.rownum rn&nbsp;</span><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >from</font></strong></span><span style="line-height: 25px;"  >&nbsp;（</span><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >select</font></strong></span><span style="line-height: 25px;"  >&nbsp;*　</span><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >from</font></strong></span><span style="line-height: 25px;"  >&nbsp;table_name） a&nbsp;</span><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >where</font></strong></span><span style="line-height: 25px;"  >&nbsp;a.rownum&lt;M)</span><span style="line-height: 25px;"  ><strong style="line-height: 25px;"  ><font color="#7f0055"  style="line-height: 25px;"  >where</font></strong></span><span style="line-height: 25px;"  >&nbsp;rn&gt;n&nbsp;</span><span style="line-height: 25px;"  ><font color="#008200"  style="line-height: 25px;"  >--这句就是从n到m也的数据，分为三层结构</font></span></span></li></ol></div></span><wbr></div>]]></description>
	    <author><![CDATA[long1]]></author>
	    <comments>http://blog.163.com/lfw2565295@126/blog/static/1220051620123101617148</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/lfw2565295@126/blog/static/1220051620123101617148</guid>
    <pubDate>Tue, 10 Apr 2012 13:06:17 +0800</pubDate>
    <dcterms:modified>2012-04-10T13:06:17+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[哈希表 百科 md5 sha1]]></title>	
    <link>http://blog.163.com/lfw2565295@126/blog/static/12200516201239101243846</link>
    <description><![CDATA[<div><h2 style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 6px; padding-left: 0px; font-size: 18px; line-height: 24px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(222, 223, 225); clear: both; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ><span><h1 style="margin-top: 0px; margin-right: 0px; margin-bottom: 25px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 30px; font-family: 微软雅黑, 黑体, Verdana; line-height: 40px; font-weight: 500; overflow-x: hidden; overflow-y: hidden;"  >哈希表</h1></span></h2><h2 style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 6px; padding-left: 0px; font-size: 18px; line-height: 24px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(222, 223, 225); clear: both; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ><span><span style="font-size: 14px; font-weight: normal; line-height: 25px;"  >散列表（Hash table，也叫哈希表），是根据关键码值(Key value)而直接进行访问的数据结构。也就是说，它通过把关键码值映射到表中一个位置来访问记录，以加快查找的速度。这个映射函数叫做散列函数，存放记录的数组叫做散列表。</span> </span></h2><h2 style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 6px; padding-left: 0px; font-size: 18px; line-height: 24px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(222, 223, 225); clear: both; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ><span>基本概念</span></h2><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　* 若结构中存在关键字和K相等的记录，则必定在f(K)的存储位置上。由此，不需比较便可直接取得所查记录。称这个对应关系f为</span><a style="color: rgb(19, 110, 194); font-family: arial, &#23435;&#20307;, sans-serif; line-height: 24px; text-align: -webkit-auto; " target="_blank" rel="nofollow" href="http://baike.baidu.com/view/131153.htm"  >散列函数</a><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >(Hash function)，按这个思想建立的表为</span><a style="color: rgb(19, 110, 194); font-family: arial, &#23435;&#20307;, sans-serif; line-height: 24px; text-align: -webkit-auto; " target="_blank" rel="nofollow" href="http://baike.baidu.com/view/1320746.htm"  >散列表</a><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >。</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　* 对不同的关键字可能得到同一散列地址，即key1≠key2，而f(key1)=f(key2)，这种现象称冲突。具有相同函数值的关键字对该散列函数来说称做同义词。综上所述，根据散列函数H(key)和处理冲突的方法将一组关键字映象到一个有限的连续的地址集（区间）上，并以关键字在地址集中的“象” 作为记录在表中的存储位置，这种表便称为散列表，这一映象过程称为散列造表或散列，所得的存储位置称散列地址。这个现象也叫散列桶，在散列桶，只能通过顺序的方式来查找，一般只需要查找三次就可以找到。科学家计算过，当重载因子不超过75%，查找效率最高。</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　* 若对于关键字集合中的任一个关键字，经散列函数映象到地址集合中任何一个地址的概率是相等的，则称此类散列函数为均匀散列函数(Uniform Hash function)，这就是使关键字经过散列函数得到一个“随机的地址”，从而减少冲突。</span><div style="height: 30px; line-height: 30px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><h2 style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 6px; padding-left: 0px; font-size: 18px; line-height: 24px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(222, 223, 225); clear: both; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ><span data-edit-id="329976:329976:2"  style="font-size: 12px; float: right; display: block; margin-top: 10px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(51, 102, 204); font-weight: normal;"  ><a style="color: rgb(19, 110, 194); height: 15px; line-height: 16px; background-image: url(http://img.baidu.com/img/baike/bk-split-icons.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; display: block; width: 52px; padding-left: 18px; background-position: 0% -108px; background-repeat: no-repeat no-repeat; " class="nslog:1019" rel="nofollow" href="http://baike.baidu.com/view/329976.htm#"  >编辑本段</a></span><a style="text-decoration: underline; color: rgb(19, 110, 194); " name="2" rel="nofollow"  ></a><a style="text-decoration: underline; color: rgb(19, 110, 194); " name="sub329976_2" rel="nofollow"  ></a><span>常用的构造散列函数的方法</span></h2><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　散列函数能使对一个数据序列的访问过程更加迅速有效，通过散列函数，数据元素将被更快地定位：</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　</span><b style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >1. 直接寻址法：</b><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >取关键字或关键字的某个线性函数值为散列地址。即H(key)=key或H(key) = a·key + b，其中a和b为常数（这种散列函数叫做自身函数）。若其中H(key)中已经有值了，就往下一个找，直到H(key)中没有值了，就放进去。</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　</span><b style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >2. 数字分析法：</b><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >分析一组数据，比如一组员工的出生年月日，这时我们发现出生年月日的前几位数字大体相同，这样的话，出现冲突的几率就会很大，但是我们发现年月日的后几位表示月份和具体日期的数字差别很大，如果用后面的数字来构成散列地址，则冲突的几率会明显降低。因此数字分析法就是找出数字的规律，尽可能利用这些数据来构造冲突几率较低的散列地址。</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　</span><b style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >3. 平方取中法：</b><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >取关键字平方后的中间几位作为散列地址。</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　</span><b style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >4. 折叠法：</b><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >将关键字分割成位数相同的几部分，最后一部分位数可以不同，然后取这几部分的叠加和（去除进位）作为散列地址。</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　</span><b style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >5. 随机数法：</b><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >选择一随机函数，取关键字的随机值作为散列地址，通常用于关键字长度不同的场合。</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　</span><b style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >6. 除留余数法：</b><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >取关键字被某个不大于散列表表长m的数p除后所得的余数为散列地址。即 H(key) = key MOD p, p&lt;=m。不仅可以对关键字直接取模，也可在折叠、平方取中等运算之后取模。对p的选择很重要，一般取素数或m，若p选的不好，容易产生同义词。</span><div style="height: 30px; line-height: 30px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><h2 style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 6px; padding-left: 0px; font-size: 18px; line-height: 24px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(222, 223, 225); clear: both; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ><span data-edit-id="329976:329976:3"  style="font-size: 12px; float: right; display: block; margin-top: 10px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(51, 102, 204); font-weight: normal;"  ><a style="color: rgb(19, 110, 194); height: 15px; line-height: 16px; background-image: url(http://img.baidu.com/img/baike/bk-split-icons.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; display: block; width: 52px; padding-left: 18px; background-position: 0% -108px; background-repeat: no-repeat no-repeat; " class="nslog:1019" rel="nofollow" href="http://baike.baidu.com/view/329976.htm#"  >编辑本段</a></span><a style="text-decoration: underline; color: rgb(19, 110, 194); " name="3" rel="nofollow"  ></a><a style="text-decoration: underline; color: rgb(19, 110, 194); " name="sub329976_3" rel="nofollow"  ></a><span>处理冲突的方法</span></h2><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　1. 开放寻址法：Hi=(H(key) + di) MOD m, i=1,2,…, k(k&lt;=m-1)，其中H(key)为散列函数，m为散列表长，di为增量序列，可有下列三种取法：</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　1.1. di=1,2,3,…, m-1，称线性探测再散列；</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　1.2. di=1^2, -1^2, 2^2,-2^2, (3)^2, …, ±(k)^2,(k&lt;=m/2)称二次探测再散列;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　1.3. di=伪随机数序列，称伪随机探测再散列。 ==</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　2. 再</span><a style="color: rgb(19, 110, 194); font-family: arial, &#23435;&#20307;, sans-serif; line-height: 24px; text-align: -webkit-auto; " target="_blank" rel="nofollow" href="http://baike.baidu.com/view/2010063.htm"  >散列法</a><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >：Hi=RHi(key), i=1,2,…,k RHi均是不同的散列函数，即在同义词产生地址冲突时计算另一个散列函数地址，直到冲突不再发生，这种方法不易产生“聚集”，但增加了计算时间。</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　3. 链地址法(拉链法)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　4. 建立一个公共溢出区</span><div style="height: 30px; line-height: 30px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><h2 style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 6px; padding-left: 0px; font-size: 18px; line-height: 24px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(222, 223, 225); clear: both; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ><span data-edit-id="329976:329976:4"  style="font-size: 12px; float: right; display: block; margin-top: 10px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(51, 102, 204); font-weight: normal;"  ><a style="color: rgb(19, 110, 194); height: 15px; line-height: 16px; background-image: url(http://img.baidu.com/img/baike/bk-split-icons.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; display: block; width: 52px; padding-left: 18px; background-position: 0% -108px; background-repeat: no-repeat no-repeat; " class="nslog:1019" rel="nofollow" href="http://baike.baidu.com/view/329976.htm#"  >编辑本段</a></span><a style="text-decoration: underline; color: rgb(19, 110, 194); " name="4" rel="nofollow"  ></a><a style="text-decoration: underline; color: rgb(19, 110, 194); " name="sub329976_4" rel="nofollow"  ></a><span>查找的性能分析</span></h2><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　散列表的查找过程基本上和造表过程相同。一些关键码可通过散列函数转换的地址直接找到，另一些关键码在散列函数得到的地址上产生了冲突，需要按处理冲突的方法进行查找。在介绍的三种处理冲突的方法中，产生冲突后的查找仍然是给定值与关键码进行比较的过程。所以，对散列表查找效率的量度，依然用平均查找长度来衡量。</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　查找过程中，关键码的比较次数，取决于产生冲突的多少，产生的冲突少，查找效率就高，产生的冲突多，查找效率就低。因此，影响产生冲突多少的因素，也就是影响查找效率的因素。影响产生冲突多少有以下三个因素：</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　1. 散列函数是否均匀；</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　2. 处理冲突的方法；</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　3. 散列表的装填因子。</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　散列表的装填因子定义为：α= 填入表中的元素个数 / 散列表的长度</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　α是散列表装满程度的标志因子。由于表长是定值，α与“填入表中的元素个数”成正比，所以，α越大，填入表中的元素较多，产生冲突的可能性就越大；α越小，填入表中的元素较少，产生冲突的可能性就越小。</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　实际上，散列表的平均查找长度是装填因子α的函数，只是不同处理冲突的方法有不同的函数。</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　了解了hash基本定义，就不能不提到一些著名的hash算法，MD5 和 SHA-1 可以说是目前应用最广泛的Hash算法，而它们都是以 MD4 为基础设计的。那么他们都是什么意思呢?</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　这里简单说一下：</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　</span><b style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >（1) MD4</b><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  ></span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　MD4(RFC 1320)是 MIT 的 Ronald L. Rivest 在 1990 年设计的，MD 是 Message Digest 的缩写。它适用在32位字长的处理器上用高速软件实现--它是基于 32 位操作数的位操作来实现的。</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　</span><b style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >（2) MD5</b><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  ></span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　MD5(RFC 1321)是 Rivest 于1991年对MD4的改进版本。它对输入仍以512位分组，其输出是4个32位字的级联，与 MD4 相同。MD5比MD4来得复杂，并且速度较之要慢一点，但更安全，在抗分析和抗差分方面表现更好</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　</span><b style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >（3) SHA-1 及其他</b><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  ></span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　SHA1是由NIST NSA设计为同DSA一起使用的，它对长度小于264的输入，产生长度为160bit的散列值，因此抗穷举(brute-force)性更好。SHA-1 设计时基于和MD4相同原理,并且模仿了该算法。</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　那么这些Hash算法到底有什么用呢?</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　Hash算法在信息安全方面的应用主要体现在以下的3个方面：</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　</span><b style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >（1) 文件校验</b><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  ></span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　我们比较熟悉的校验算法有奇偶校验和CRC校验，这2种校验并没有抗数据篡改的能力，它们一定程度上能检测并纠正数据传输中的信道误码，但却不能防止对数据的恶意破坏。</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　MD5 Hash算法的"数字指纹"特性，使它成为目前应用最广泛的一种文件完整性校验和(Checksum)算法，不少Unix系统有提供计算md5 checksum的命令。</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　</span><b style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >（2) 数字签名</b><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  ></span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　Hash 算法也是现代密码体系中的一个重要组成部分。由于非对称算法的运算速度较慢，所以在数字签名协议中，单向散列函数扮演了一个重要的角色。 对 Hash 值，又称"数字摘要"进行数字签名，在统计上可以认为与对文件本身进行数字签名是等效的。而且这样的协议还有其他的优点。</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　</span><b style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >（3) 鉴权协议</b><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  ></span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　如下的鉴权协议又被称作挑战--认证模式：在传输信道是可被侦听，但不可被篡改的情况下，这是一种简单而安全的方法。</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　</span><b style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >MD5、SHA1的破解</b><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  ></span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　2004年8月17日，在美国加州圣</span><a style="color: rgb(19, 110, 194); font-family: arial, &#23435;&#20307;, sans-serif; line-height: 24px; text-align: -webkit-auto; " target="_blank" rel="nofollow" href="http://baike.baidu.com/view/1013962.htm"  >芭芭拉</a><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >召开的国际密码大会上，山东大学王小云教授在国际会议上首次宣布了她及她的研究小组近年来的研究成果——对MD5、HAVAL－128、MD4和RIPEMD等四个著名密码算法的破译结果。 次年二月宣布破解SHA-1密码。</span><div style="height: 30px; line-height: 30px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><h2 style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 6px; padding-left: 0px; font-size: 18px; line-height: 24px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(222, 223, 225); clear: both; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ><span data-edit-id="329976:329976:5"  style="font-size: 12px; float: right; display: block; margin-top: 10px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(51, 102, 204); font-weight: normal;"  ><a style="color: rgb(19, 110, 194); height: 15px; line-height: 16px; background-image: url(http://img.baidu.com/img/baike/bk-split-icons.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; display: block; width: 52px; padding-left: 18px; background-position: 0% -108px; background-repeat: no-repeat no-repeat; " class="nslog:1019" rel="nofollow" href="http://baike.baidu.com/view/329976.htm#"  >编辑本段</a></span><a style="text-decoration: underline; color: rgb(19, 110, 194); " name="5" rel="nofollow"  ></a><a style="text-decoration: underline; color: rgb(19, 110, 194); " name="sub329976_5" rel="nofollow"  ></a><span>实际应用</span></h2><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　以上就是一些关于hash以及其相关的一些基本预备知识。那么在emule里面他具体起到什么作用呢?</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　大家都知道emule是基于P2P （Peer-to-peer的缩写，指的是点对点的意思的软件）， 它采用了"多源文件传输协议”(MFTP，the Multisource FileTransfer Protocol)。在协议中，定义了一系列传输、压缩和打包还有积分的标准，emule 对于每个文件都有md5-hash的算法设置，这使得该文件独一无二，并且在整个网络上都可以追踪得到。</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　什么是文件的hash值呢?</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　MD5-Hash-文件的数字文摘通过Hash函数计算得到。不管文件长度如何，它的Hash函数计算结果是一个固定长度的数字。与加密算法不同，这一个Hash算法是一个不可逆的单向函数。采用安全性高的Hash算法，如MD5、SHA时，两个不同的文件几乎不可能得到相同的Hash结果。因此，一旦文件被修改，就可检测出来。</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　当我们的文件放到emule里面进行共享发布的时候，emule会根据hash算法自动生成这个文件的hash值，他就是这个文件唯一的身份标志，它包含了这个文件的基本信息,然后把它提交到所连接的服务器。当有他人想对这个文件提出下载请求的时候， 这个hash值可以让他人知道他正在下载的文件是不是就是他所想要的。尤其是在文件的其他属性被更改之后（如名称等）这个值就更显得重要。而且服务器还提供了,这个文件当前所在的用户的地址,端口等信息,这样emule就知道到哪里去下载了。</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　一般来讲我们要搜索一个文件，emule在得到了这个信息后，会向被添加的服务器发出请求，要求得到有相同hash值的文件。而服务器则返回持有这个文件的用户信息。这样我们的客户端就可以直接的和拥有那个文件的用户沟通，看看是不是可以从他那里下载所需的文件。</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　对于emule中文件的hash值是固定的，也是唯一的，它就相当于这个文件的信息摘要，无论这个文件在谁的机器上，他的hash值都是不变的，无论过了多长时间，这个值始终如一，当我们在进行文件的下载上传过程中，emule都是通过这个值来确定文件。</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　那么什么是userhash呢?</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　道理同上，当我们在第一次使用emule的时候，emule会自动生成一个值，这个值也是唯一的，它是我们在emule世界里面的标志，只要你不卸载，不删除config，你的userhash值也就永远不变，积分制度就是通过这个值在起作用，emule里面的积分保存，身份识别，都是使用这个值，而和你的id和你的用户名无关，你随便怎么改这些东西，你的userhash值都是不变的，这也充分保证了公平性。其实他也是一个信息摘要，只不过保存的不是文件信息，而是我们每个人的信息。</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　那么什么是hash文件呢?</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　我们经常在emule日志里面看到，emule正在hash文件，这里就是利用了hash算法的文件校验性这个功能了，文章前面已经说了一些这些功能，其实这部分是一个非常复杂的过程，目前在ftp,bt等软件里面都是用的这个基本原理，emule里面是采用文件分块传输，这样传输的每一块都要进行对比校验，如果错误则要进行重新下载，这期间这些相关信息写入met文件，直到整个任务完成，这个时候part文件进行重新命名，然后使用move命令，把它传送到incoming文件里面，然后met文件自动删除，所以我们有的时候会遇到hash文件失败，就是指的是met里面的信息出了错误不能够和part文件匹配，另外有的时候开机也要疯狂hash，有两种情况一种是你在第一次使用，这个时候要hash提取所有文件信息，还有一种情况就是上一次你非法关机，那么这个时候就是要进行排错校验了。</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　关于hash的算法研究，一直是信息科学里面的一个前沿，尤其在网络技术普及的今天，他的重要性越来越突出，其实我们每天在网上进行的信息交流安全验证，我们在使用的操作系统密钥原理，里面都有它的身影，特别对于那些研究信息安全有兴趣的朋友，这更是一个打开信息世界的钥匙，他在hack世界里面也是一个研究的焦点。</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　一般的线性表、树中，记录在结构中的相对位置是随机的即和记录的关键字之间不存在确定的关系，在结构中查找记录时需进行一系列和关键字的比较。这一类查找方法建立在“比较”的基础上，查找的效率与比较次数密切相关。理想的情况是能直接找到需要的记录，因此必须在记录的存储位置和它的关键字之间建立一确定的对应关系f，使每个关键字和结构中一个唯一的存储位置相对应。因而查找时，只需根据这个对应关系f找到给定值K的像f(K)。若结构中存在关键字和K相等的记录，则必定在f(K)的存储位置上，由此不需要进行比较便可直接取得所查记录。在此，称这个对应关系f为</span><a style="color: rgb(19, 110, 194); font-family: arial, &#23435;&#20307;, sans-serif; line-height: 24px; text-align: -webkit-auto; " target="_blank" rel="nofollow" href="http://baike.baidu.com/view/549615.htm"  >哈希函数</a><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >，按这个思想建立的表为哈希表（又称为杂凑法或散列表）。</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　哈希表不可避免冲突(collision)现象：对不同的关键字可能得到同一哈希地址 即key1≠key2，而hash(key1)=hash(key2)。具有相同函数值的关键字对该哈希函数来说称为同义词(synonym)。 因此，在建造哈希表时不仅要设定一个好的哈希函数，而且要设定一种处理冲突的方法。可如下描述哈希表：根据设定的哈希函数H(key)和所选中的处理冲突的方法，将一组关键字映象到一个有限的、地址连续的地址集(区间)上并以关键字在地址集中的“象”作为相应记录在表中的存储位置，这种表被称为哈希表。</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　对于动态查找表而言，1) 表长不确定；2)在设计查找表时，只知道关键字所属范围，而不知道确切的关键字。因此，一般情况需建立一个函数关系，以f(key)作为关键字为key的录在表中的位置，通常称这个函数f(key)为哈希函数。(注意：这个函数并不一定是数学函数)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　哈希函数是一个映象，即：将关键字的集合映射到某个地址集合上，它的设置很灵活，只要这个地址集合的大小不超出允许范围即可。</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　现实中哈希函数是需要构造的，并且构造的好才能使用的好。</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　用途：加密，解决冲突问题。。。。</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　用途很广，比特精灵中就使用了哈希函数，你可 以自己看看。</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　具体可以学习一下数据结构和算法的书。</span><div style="height: 30px; line-height: 30px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><h2 style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 6px; padding-left: 0px; font-size: 18px; line-height: 24px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(222, 223, 225); clear: both; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ><span data-edit-id="329976:329976:6"  style="font-size: 12px; float: right; display: block; margin-top: 10px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(51, 102, 204); font-weight: normal;"  ><a style="color: rgb(19, 110, 194); height: 15px; line-height: 16px; background-image: url(http://img.baidu.com/img/baike/bk-split-icons.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; display: block; width: 52px; padding-left: 18px; background-position: 0% -108px; background-repeat: no-repeat no-repeat; " class="nslog:1019" rel="nofollow" href="http://baike.baidu.com/view/329976.htm#"  >编辑本段</a></span><a style="text-decoration: underline; color: rgb(19, 110, 194); " name="6" rel="nofollow"  ></a><a style="text-decoration: underline; color: rgb(19, 110, 194); " name="sub329976_6" rel="nofollow"  ></a><span>字符串哈希函数</span></h2><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　（著名的ELFhash算法）</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　int ELFhash(char *key)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　unsigned long h=0;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　while(*key)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　{</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　h=(h&lt;&lt;4)+*key++;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　unsigned long g=h&amp;0Xf0000000L;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　if(g)</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　h^=g&gt;&gt;24;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　h&amp;=~g;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　return h%MOD;</span><div style="height: 14px; line-height: 14px; font-size: 12px; overflow-x: hidden; overflow-y: hidden; font-family: arial, 宋体, sans-serif; text-align: -webkit-auto;"  ></div><span style="font-family: arial, 宋体, sans-serif; line-height: 24px; text-align: -webkit-auto;"  >　　}</span><wbr></div>]]></description>
	    <author><![CDATA[long1]]></author>
	    <comments>http://blog.163.com/lfw2565295@126/blog/static/12200516201239101243846</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/lfw2565295@126/blog/static/12200516201239101243846</guid>
    <pubDate>Mon, 9 Apr 2012 22:12:43 +0800</pubDate>
    <dcterms:modified>2012-04-09T22:12:43+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[子串问题 和 模式匹配(kmp)]]></title>	
    <link>http://blog.163.com/lfw2565295@126/blog/static/12200516201239111536401</link>
    <description><![CDATA[<div><h1 style="margin-top: 0px; margin-right: 0px; margin-bottom: 25px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; overflow-x: hidden; overflow-y: hidden; text-align: -webkit-auto;"  ><p style="font-family: 微软雅黑, 黑体, Verdana; margin-bottom: 18.75pt; line-height: 30pt;"  ><b><span style="font-size: 18.0pt;"  sans-serifmso-bidi-font-familycolorblue=""  mso-font-kerningpt=""  >子串：</span></b><span style="font-size:18.0pt;"  sans-serifmso-ascii-font-familyarialmso-hansi-font-family=""  arialmso-bidi-font-familyarialmso-font-kerningpt=""  >对于一个字符串变量，例如</span><span lang="EN-US"  style="font-size:18.0pt;"  arialsans-serifmso-font-kerning=""  pt=""  >"adereegfbw",</span><span style="font-size:18.0pt;font-family: ;"  sans-serifmso-ascii-font-familyarialmso-hansi-font-familyarial=""  mso-bidi-font-familyarialmso-font-kerningpt=""  >它的子串就是像</span><span lang="EN-US"  style="font-size:18.0pt;"  arialsans-serifmso-font-kerning=""  pt=""  >"ader"</span><span style="font-size:18.0pt;"  sans-serif=""  mso-ascii-font-familyarialmso-hansi-font-familyarialmso-bidi-font-family=""  arialmso-font-kerningpt=""  >这样可以从中找到的<b><span style="color:blue;"  >连续</span></b>的字符串。字符串</span><span lang="EN-US"  style="font-size:18.0pt;"  arialsans-serifmso-font-kerning=""  pt=""  >"adereegfbw"</span><span style="font-size:18.0pt;font-family: ;"  sans-serifmso-ascii-font-familyarialmso-hansi-font-familyarial=""  mso-bidi-font-familyarialmso-font-kerningpt=""  >本身也属于它本身<span style="color:blue;"  >最长</span>的子串。</span><b><span lang="EN-US"  style="font-size: 24.0pt;"  sans-serifmso-bidi-font-familymso-font-kerning=""  pt=""  ></span></b></p>  <p style="font-family: 微软雅黑, 黑体, Verdana; margin-bottom: 0.0001pt;"  ><b><span style="font-size:18.0pt;font-family:宋体;mso-ascii-font-family:Arial;mso-hansi-font-family: Arial;mso-bidi-font-family:Arial;color:blue;"  >子串计算方法：</span></b><span lang="EN-US"  style="font-size:12.0pt;font-family:宋体;mso-bidi-font-family:宋体;"  ></span></p>  <p style="font-family: 微软雅黑, 黑体, Verdana; margin-bottom: 0.0001pt; line-height: 16.5pt;"  ><span lang="EN-US"  style="font-size:13.5pt;"  arialsans-serifmso-fareast-font-family=""  >&nbsp; &nbsp; &nbsp; &nbsp;ab</span><span style="font-size:13.5pt; font-family:宋体;mso-ascii-font-family:Arial;mso-hansi-font-family:Arial; mso-bidi-font-family:Arial;"  >的子串：</span><span lang="EN-US"  style="font-size:13.5pt;"  arialsans-serifmso-fareast-font-family=""  >a</span><span style="font-size:13.5pt;font-family:宋体;mso-ascii-font-family:Arial;mso-hansi-font-family: Arial;mso-bidi-font-family:Arial;"  >、</span><span lang="EN-US"  style="font-size: 13.5pt;"  arialsans-serifmso-fareast-font-family=""  >b</span><span style="font-size:13.5pt;font-family:宋体;mso-ascii-font-family:Arial;mso-hansi-font-family: Arial;mso-bidi-font-family:Arial;"  >、</span><span lang="EN-US"  style="font-size: 13.5pt;"  arialsans-serifmso-fareast-font-family=""  >ab</span><span style="font-size:13.5pt;font-family:宋体;mso-ascii-font-family:Arial;mso-hansi-font-family: Arial;mso-bidi-font-family:Arial;"  >共</span><span lang="EN-US"  style="font-size: 13.5pt;"  arialsans-serifmso-fareast-font-family=""  >3</span><span style="font-size:13.5pt;font-family:宋体;mso-ascii-font-family:Arial;mso-hansi-font-family: Arial;mso-bidi-font-family:Arial;"  >个即（</span><span lang="EN-US"  style="font-size: 13.5pt;"  arialsans-serifmso-fareast-font-family=""  >2+1</span><span style="font-size:13.5pt;font-family:宋体;mso-ascii-font-family:Arial;mso-hansi-font-family: Arial;mso-bidi-font-family:Arial;"  >）个，</span><span lang="EN-US"  style="font-size: 13.5pt;"  arialsans-serifmso-fareast-font-family=""  >abc</span><span style="font-size:13.5pt;font-family:宋体;mso-ascii-font-family:Arial;mso-hansi-font-family: Arial;mso-bidi-font-family:Arial;"  >的子串：</span><span lang="EN-US"  style="font-size: 13.5pt;"  arialsans-serifmso-fareast-font-family=""  >a</span><span style="font-size:13.5pt;font-family:宋体;mso-ascii-font-family:Arial;mso-hansi-font-family: Arial;mso-bidi-font-family:Arial;"  >、</span><span lang="EN-US"  style="font-size: 13.5pt;"  arialsans-serifmso-fareast-font-family=""  > b</span><span style="font-size:13.5pt;font-family:宋体;mso-ascii-font-family:Arial;mso-hansi-font-family: Arial;mso-bidi-font-family:Arial;"  >、</span><span lang="EN-US"  style="font-size: 13.5pt;"  arialsans-serifmso-fareast-font-family=""  > c</span><span style="font-size:13.5pt;font-family:宋体;mso-ascii-font-family:Arial;mso-hansi-font-family: Arial;mso-bidi-font-family:Arial;"  >、</span><span lang="EN-US"  style="font-size: 13.5pt;"  arialsans-serifmso-fareast-font-family=""  > ab</span><span style="font-size:13.5pt;font-family:宋体;mso-ascii-font-family:Arial;mso-hansi-font-family: Arial;mso-bidi-font-family:Arial;"  >、</span><span lang="EN-US"  style="font-size: 13.5pt;"  arialsans-serifmso-fareast-font-family=""  > bc </span><span style="font-size:13.5pt;font-family:宋体;mso-ascii-font-family:Arial;mso-hansi-font-family: Arial;mso-bidi-font-family:Arial;"  >、</span><span lang="EN-US"  style="font-size: 13.5pt;"  arialsans-serifmso-fareast-font-family=""  >abc </span><span style="font-size:13.5pt;font-family:宋体;mso-ascii-font-family:Arial;mso-hansi-font-family: Arial;mso-bidi-font-family:Arial;"  >共（</span><span lang="EN-US"  style="font-size: 13.5pt;"  arialsans-serifmso-fareast-font-family=""  >3+2+1</span><span style="font-size:13.5pt;font-family:宋体;mso-ascii-font-family:Arial;mso-hansi-font-family: Arial;mso-bidi-font-family:Arial;"  >）个，所以若字符串的长度为</span><span lang="EN-US"  style="font-size:13.5pt;"  arialsans-serifmso-fareast-font-family=""  >n,</span><span style="font-size:13.5pt;font-family:宋体;mso-ascii-font-family: Arial;mso-hansi-font-family:Arial;mso-bidi-font-family:Arial;"  >则子串的个数就是</span><span lang="EN-US"  style="font-size:13.5pt;"  arialsans-serifmso-fareast-font-family=""  >[n+(n-1)+.......+1]</span><span style="font-size:13.5pt;font-family:宋体; mso-ascii-font-family:Arial;mso-hansi-font-family:Arial;mso-bidi-font-family: Arial;"  >个，</span><span lang="EN-US"  style="font-size:13.5pt;"  arialsans-serif=""  mso-fareast-font-family=""  >"software"</span><span style="font-size: 13.5pt;font-family:宋体;mso-ascii-font-family:Arial;mso-hansi-font-family:Arial; mso-bidi-font-family:Arial;"  >中非空子串的个数就是</span><span lang="EN-US"  style="font-size: 13.5pt;"  arialsans-serifmso-fareast-font-family=""  >8+7+....+1=36</span><span style="font-size:13.5pt;font-family:宋体;mso-ascii-font-family:Arial;mso-hansi-font-family: Arial;mso-bidi-font-family:Arial;"  >个，如果包括空串</span><span lang="EN-US"  style="font-size:13.5pt;"  arialsans-serifmso-fareast-font-family=""  >,</span><span style="font-size:13.5pt;font-family:宋体;mso-ascii-font-family: Arial;mso-hansi-font-family:Arial;mso-bidi-font-family:Arial;"  >则应为</span><span lang="EN-US"  style="font-size:13.5pt;"  arialsans-serifmso-fareast-font-family=""  >37</span><span style="font-size:13.5pt;font-family:宋体;mso-ascii-font-family: Arial;mso-hansi-font-family:Arial;mso-bidi-font-family:Arial;"  >个。</span><span lang="EN-US"  style="font-size:12.0pt;font-family:宋体;mso-bidi-font-family:宋体;"  ></span></p>  <p style="font-family: 微软雅黑, 黑体, Verdana; margin-bottom: 0.0001pt; line-height: 16.5pt;"  ><span lang="EN-US"  style="font-size:12.0pt;font-family:宋体;mso-bidi-font-family:宋体;"  >&nbsp;</span></p>  <p style="font-family: 微软雅黑, 黑体, Verdana; margin-bottom: 0.0001pt;"  ><b><span style="font-size:18.0pt;font-family:宋体;mso-ascii-font-family:Arial;mso-hansi-font-family: Arial;mso-bidi-font-family:Arial;"  >串的模式匹配</span></b><b><span lang="EN-US"  style="font-size:18.0pt;"  arialsans-serifmso-fareast-font-family=""  >(kmp)</span></b><b><span style="font-size:24.0pt;font-family:宋体;mso-ascii-font-family: Arial;mso-hansi-font-family:Arial;mso-bidi-font-family:Arial;"  >：</span></b><span lang="EN-US"  style="font-size:12.0pt;font-family:宋体;mso-bidi-font-family:宋体;"  ></span></p>  <p style="font-family: 微软雅黑, 黑体, Verdana; margin-bottom: 0.0001pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; background-position: initial initial; background-repeat: initial initial;"  ><i><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorbrown=""  >KMP, s</span></i><i><span style="font-size:13.5pt;mso-bidi-font-size:11.0pt;font-family:宋体;mso-ascii-font-family: ;"  courier=""  newmso-hansi-font-familycourier=""  newmso-bidi-font-familycourier=""  new=""  colorbrown=""  >主串，</span></i><i><span lang="EN-US"  style="font-size:13.5pt; mso-bidi-font-size:11.0pt;"  courier=""  newmso-fareast-font-family=""  colorbrown=""  >t</span></i><i><span style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;font-family:宋体;"  courier=""  newmso-hansi-font-family=""  courier=""  newmso-bidi-font-familycourier=""  newcolorbrown=""  >模式串</span></i><i><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorbrown=""  > (</span></i><i><span style="font-size: 13.5pt;mso-bidi-font-size:11.0pt;font-family:宋体;"  courier=""  new=""  mso-hansi-font-familycourier=""  newmso-bidi-font-familycourier=""  colorbrown=""  >存储方式由</span></i><i><span lang="EN-US"  style="font-size:13.5pt; mso-bidi-font-size:11.0pt;"  courier=""  newmso-fareast-font-family=""  colorbrown=""  >1</span></i><i><span style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;font-family:宋体;"  courier=""  newmso-hansi-font-family=""  courier=""  newmso-bidi-font-familycourier=""  newcolorbrown=""  >开始到</span></i><i><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorbrown=""  >n,1..m)</span></i><span lang="EN-US"  style="font-size:13.5pt;"  courier=""  newmso-fareast-font-family=""  ></span></p>  <p style="font-family: 微软雅黑, 黑体, Verdana; margin-bottom: 0.0001pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; background-position: initial initial; background-repeat: initial initial;"  ><i><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorbrown=""  >i</span></i><i><span style="font-size: 13.5pt;mso-bidi-font-size:11.0pt;font-family:宋体;"  courier=""  new=""  mso-hansi-font-familycourier=""  newmso-bidi-font-familycourier=""  colorbrown=""  >不回溯，</span></i><i><span lang="EN-US"  style="font-size:13.5pt; mso-bidi-font-size:11.0pt;"  courier=""  newmso-fareast-font-family=""  colorbrown=""  >j</span></i><i><span style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;font-family:宋体;"  courier=""  newmso-hansi-font-family=""  courier=""  newmso-bidi-font-familycourier=""  newcolorbrown=""  >回溯到某个位置</span></i><i><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorbrown=""  >k,si</span></i><i><span style="font-size:13.5pt;mso-bidi-font-size:11.0pt;font-family:宋体;mso-ascii-font-family: ;"  courier=""  newmso-hansi-font-familycourier=""  newmso-bidi-font-familycourier=""  new=""  colorbrown=""  >与</span></i><i><span lang="EN-US"  style="font-size:13.5pt; mso-bidi-font-size:11.0pt;"  courier=""  newmso-fareast-font-family=""  colorbrown=""  >tk</span></i><i><span style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;font-family:宋体;"  courier=""  newmso-hansi-font-family=""  courier=""  newmso-bidi-font-familycourier=""  newcolorbrown=""  >比较</span></i><span lang="EN-US"  style="font-size:13.5pt;"  courier=""  newmso-fareast-font-family=""  ></span></p>  <p style="font-family: 微软雅黑, 黑体, Verdana; margin-bottom: 0.0001pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; background-position: initial initial; background-repeat: initial initial;"  ><i><span style="font-size:13.5pt;mso-bidi-font-size:11.0pt;font-family:宋体;mso-ascii-font-family: ;"  courier=""  newmso-hansi-font-familycourier=""  newmso-bidi-font-familycourier=""  new=""  colorbrown=""  >当</span></i><i><span lang="EN-US"  style="font-size:13.5pt; mso-bidi-font-size:11.0pt;"  courier=""  newmso-fareast-font-family=""  colorbrown=""  >si!=sj</span></i><i><span style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;font-family:宋体;"  courier=""  newmso-hansi-font-family=""  courier=""  newmso-bidi-font-familycourier=""  newcolorbrown=""  >时：</span></i><i><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorbrown=""  >"s[i-k+1]s[s-k+2]..s[i-1]" == "t[1]t[2]..t[k-1]" </span></i><i><span style="font-size:13.5pt; mso-bidi-font-size:11.0pt;font-family:宋体;"  courier=""  new=""  mso-hansi-font-familycourier=""  newmso-bidi-font-familycourier=""  colorbrown=""  >前</span></i><i><span lang="EN-US"  style="font-size:13.5pt; mso-bidi-font-size:11.0pt;"  courier=""  newmso-fareast-font-family=""  colorbrown=""  >k-1</span></i><i><span style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;font-family:宋体;"  courier=""  newmso-hansi-font-family=""  courier=""  newmso-bidi-font-familycourier=""  newcolorbrown=""  >个字符一样</span></i><i><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorbrown=""  > k&lt;j</span></i><span lang="EN-US"  style="font-size:13.5pt;"  courier=""  newmso-fareast-font-family=""  ></span></p>  <p style="font-family: 微软雅黑, 黑体, Verdana; margin-bottom: 0.0001pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; background-position: initial initial; background-repeat: initial initial;"  ><i><span style="font-size:13.5pt;mso-bidi-font-size:11.0pt;font-family:宋体;mso-ascii-font-family: ;"  courier=""  newmso-hansi-font-familycourier=""  newmso-bidi-font-familycourier=""  new=""  colorbrown=""  >同时</span></i><i><span lang="EN-US"  style="font-size:13.5pt; mso-bidi-font-size:11.0pt;"  courier=""  newmso-fareast-font-family=""  colorbrown=""  > "s[i-k+1]s[s-k+2]..s[i-1]" == "t[j-k+1]t[j-k+2]..t[j-1]";</span></i><span lang="EN-US"  style="font-size:13.5pt;"  courier=""  newmso-fareast-font-family=""  ></span></p>  <p style="font-family: 微软雅黑, 黑体, Verdana; margin-bottom: 0.0001pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; background-position: initial initial; background-repeat: initial initial;"  ><i><span style="font-size:13.5pt;mso-bidi-font-size:11.0pt;font-family:宋体;mso-ascii-font-family: ;"  courier=""  newmso-hansi-font-familycourier=""  newmso-bidi-font-familycourier=""  new=""  colorbrown=""  >则：</span></i><i><span lang="EN-US"  style="font-size:13.5pt; mso-bidi-font-size:11.0pt;"  courier=""  newmso-fareast-font-family=""  colorbrown=""  >&nbsp; "t[1]t[2]..t[k-1]" == "t[j-k+1]t[j-k+2]..t[j-1]"</span></i><span lang="EN-US"  style="font-size:13.5pt;"  courier=""  newmso-fareast-font-family=""  ></span></p>  <p style="font-family: 微软雅黑, 黑体, Verdana; margin-bottom: 0.0001pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; background-position: initial initial; background-repeat: initial initial;"  ><i><span style="font-size:13.5pt;mso-bidi-font-size:11.0pt;font-family:宋体;mso-ascii-font-family: ;"  courier=""  newmso-hansi-font-familycourier=""  newmso-bidi-font-familycourier=""  new=""  colorbrown=""  >依赖本模式</span></i><i><span lang="EN-US"  style="font-size:13.5pt; mso-bidi-font-size:11.0pt;"  courier=""  newmso-fareast-font-family=""  colorbrown=""  >t</span></i><i><span style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;font-family:宋体;"  courier=""  newmso-hansi-font-family=""  courier=""  newmso-bidi-font-familycourier=""  newcolorbrown=""  >本身字符序列的构成</span></i><span lang="EN-US"  style="font-size:13.5pt;"  courier=""  newmso-fareast-font-family=""  ></span></p>  <p style="font-family: 微软雅黑, 黑体, Verdana; margin-bottom: 0.0001pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; background-position: initial initial; background-repeat: initial initial;"  ><i><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorbrown=""  >next[j] </span></i><i><span style="font-size:13.5pt;mso-bidi-font-size:11.0pt;font-family:宋体;mso-ascii-font-family: ;"  courier=""  newmso-hansi-font-familycourier=""  newmso-bidi-font-familycourier=""  new=""  colorbrown=""  >是一个整数</span></i><i><span lang="EN-US"  style="font-size:13.5pt; mso-bidi-font-size:11.0pt;"  courier=""  newmso-fareast-font-family=""  colorbrown=""  > -1&lt;=next[j]&lt;j </span></i><i><span style="font-size:13.5pt; mso-bidi-font-size:11.0pt;font-family:宋体;"  courier=""  new=""  mso-hansi-font-familycourier=""  newmso-bidi-font-familycourier=""  colorbrown=""  >取最大的可能</span></i><i><span lang="EN-US"  style="font-size:13.5pt; mso-bidi-font-size:11.0pt;"  courier=""  newmso-fareast-font-family=""  colorbrown=""  >k</span></i></p><p style="font-family: 微软雅黑, 黑体, Verdana; margin-bottom: 0.0001pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; background-position: initial initial; background-repeat: initial initial;"  ><span lang="EN-US"  style="font-size: 13.5pt;"  courier=""  newmso-fareast-font-family=""  colorbrown=""  ><font color="#0000ff"  >可以理解为这点之前，有多少个点，与初始的多少个点一致。</font></span></p><p style="font-family: 微软雅黑, 黑体, Verdana; margin-bottom: 0.0001pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; background-position: initial initial; background-repeat: initial initial;"  ><span lang="EN-US"  style="font-size: 13.5pt;"  courier=""  newmso-fareast-font-family=""  colorbrown=""  ><font color="#0000ff"  >接下来编号改为0~len-1，方便编程</font></span></p>  <p style="font-family: 微软雅黑, 黑体, Verdana; margin-bottom: 0.0001pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; background-position: initial initial; background-repeat: initial initial;"  ><i><span style="font-size:13.5pt;mso-bidi-font-size:11.0pt;font-family:宋体;mso-ascii-font-family: ;"  courier=""  newmso-hansi-font-familycourier=""  newmso-bidi-font-familycourier=""  new=""  colorbrown=""  >则</span></i><i><span lang="EN-US"  style="font-size:13.5pt; mso-bidi-font-size:11.0pt;"  courier=""  newmso-fareast-font-family=""  colorbrown=""  >next[j]= (1) -1 (j==0) </span></i><span lang="EN-US"  style="font-size:13.5pt;"  courier=""  newmso-fareast-font-family=""  ></span></p>  <p style="font-family: 微软雅黑, 黑体, Verdana; margin-bottom: 0.0001pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; background-position: initial initial; background-repeat: initial initial;"  ><i><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorbrown=""  >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (2) max{k| 0&lt;k&lt;j &amp; "t[0]t[1]..t[k-1]" == "t[j-k]t[j-k+1]..t[j-1]"}</span></i><span lang="EN-US"  style="font-size:13.5pt;"  courier=""  newmso-fareast-font-family=""  ></span></p>  <p style="font-family: 微软雅黑, 黑体, Verdana; margin-bottom: 0.0001pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; background-position: initial initial; background-repeat: initial initial;"  ><i><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorbrown=""  >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (3) 0</span></i><span lang="EN-US"  style="font-size:13.5pt;"  courier=""  newmso-fareast-font-family=""  ></span></p>  <p style="font-family: 微软雅黑, 黑体, Verdana; margin-bottom: 0.0001pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; background-position: initial initial; background-repeat: initial initial;"  ><i><span style="font-size:13.5pt;mso-bidi-font-size:11.0pt;font-family:宋体;mso-ascii-font-family: ;"  courier=""  newmso-hansi-font-familycourier=""  newmso-bidi-font-familycourier=""  new=""  colorbrown=""  >但对</span></i><i><span lang="EN-US"  style="font-size:13.5pt; mso-bidi-font-size:11.0pt;"  courier=""  newmso-fareast-font-family=""  colorbrown=""  >next</span></i><i><span style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;font-family:宋体;"  courier=""  newmso-hansi-font-family=""  courier=""  newmso-bidi-font-familycourier=""  newcolorbrown=""  >值，还需要递归调整</span></i><i><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorbrown=""  >t[next[]],</span></i><i><span style="font-size:13.5pt;mso-bidi-font-size:11.0pt;font-family:宋体;mso-ascii-font-family: ;"  courier=""  newmso-hansi-font-familycourier=""  newmso-bidi-font-familycourier=""  new=""  colorbrown=""  >用递归的方法求</span></i><i><span lang="EN-US"  style="font-size:13.5pt; mso-bidi-font-size:11.0pt;"  courier=""  newmso-fareast-font-family=""  colorbrown=""  >next</span></i><i><span style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;font-family:宋体;"  courier=""  newmso-hansi-font-family=""  courier=""  newmso-bidi-font-familycourier=""  newcolorbrown=""  >函数值</span></i><i><span style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorbrown=""  > </span></i><i><span style="font-size: 13.5pt;mso-bidi-font-size:11.0pt;font-family:宋体;"  courier=""  new=""  mso-hansi-font-familycourier=""  newmso-bidi-font-familycourier=""  colorbrown=""  >初始：</span></i><i><span lang="EN-US"  style="font-size:13.5pt; mso-bidi-font-size:11.0pt;"  courier=""  newmso-fareast-font-family=""  colorbrown=""  >next[1]=0;</span></i><span lang="EN-US"  style="font-size:13.5pt;"  courier=""  newmso-fareast-font-family=""  ></span></p>  <p style="font-family: 微软雅黑, 黑体, Verdana; margin-bottom: 0.0001pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; background-position: initial initial; background-repeat: initial initial;"  ><i><span style="font-size:13.5pt;mso-bidi-font-size:11.0pt;font-family:宋体;mso-ascii-font-family: ;"  courier=""  newmso-hansi-font-familycourier=""  newmso-bidi-font-familycourier=""  new=""  colorbrown=""  >因为对于本身的</span></i><i><span lang="EN-US"  style="font-size:13.5pt; mso-bidi-font-size:11.0pt;"  courier=""  newmso-fareast-font-family=""  colorbrown=""  >t</span></i><i><span style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;font-family:宋体;"  courier=""  newmso-hansi-font-family=""  courier=""  newmso-bidi-font-familycourier=""  newcolorbrown=""  >串，也是模式匹配的问题，采用压缩路径的方式，复杂度</span></i><i><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorbrown=""  >O(n+m) </span></i><span lang="EN-US"  style="font-size:13.5pt;"  courier=""  newmso-fareast-font-family=""  ></span></p>  <p style="font-family: 微软雅黑, 黑体, Verdana; margin-bottom: 0.0001pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; background-position: initial initial; background-repeat: initial initial;"  ><span lang="EN-US"  style="font-size:13.5pt;"  courier=""  newmso-fareast-font-family=""  >&nbsp;</span></p>  <p style="font-family: 微软雅黑, 黑体, Verdana; margin-bottom: 0.0001pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; background-position: initial initial; background-repeat: initial initial;"  ><i><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorbrown=""  >&nbsp;</span></i></p>  <p style="font-family: 微软雅黑, 黑体, Verdana; margin-bottom: 0.0001pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; background-position: initial initial; background-repeat: initial initial;"  ><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolordarkgreen=""  >char</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  > a</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;"  courier=""  newmso-fareast-font-familycolordarkred=""  >[</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorpurple=""  >10001</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolordarkred=""  >],</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  >b</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;"  courier=""  newmso-fareast-font-familycolordarkred=""  >[</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorpurple=""  >1000001</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolordarkred=""  >];</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  ></span></p>  <p style="font-family: 微软雅黑, 黑体, Verdana; margin-bottom: 0.0001pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; background-position: initial initial; background-repeat: initial initial;"  ><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolordarkgreen=""  >int</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  > next</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;"  courier=""  newmso-fareast-font-familycolordarkred=""  >[</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorpurple=""  >10001</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolordarkred=""  >],</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  >la</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;"  courier=""  newmso-fareast-font-familycolordarkred=""  >,</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  >lb</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;"  courier=""  newmso-fareast-font-familycolordarkred=""  >;</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  ></span></p>  <p style="font-family: 微软雅黑, 黑体, Verdana; margin-bottom: 0.0001pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; background-position: initial initial; background-repeat: initial initial;"  ><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolordarkgreen=""  >void</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  > </span><b><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  >getNext</span></b><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolordarkred=""  >()</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorred=""  >{</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  ></span></p>  <p style="font-family: 微软雅黑, 黑体, Verdana; margin-bottom: 0.0001pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; background-position: initial initial; background-repeat: initial initial;"  ><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolordarkgreen=""  >int</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  > i</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;"  courier=""  newmso-fareast-font-familycolordarkred=""  >=</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorpurple=""  >0</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolordarkred=""  >,</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  >j</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;"  courier=""  newmso-fareast-font-familycolordarkred=""  >=-</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorpurple=""  >1</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolordarkred=""  >;</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  > next</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;"  courier=""  newmso-fareast-font-familycolordarkred=""  >[</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorpurple=""  >0</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolordarkred=""  >]=-</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorpurple=""  >1</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolordarkred=""  >;</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  ></span></p>  <p style="font-family: 微软雅黑, 黑体, Verdana; margin-bottom: 0.0001pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; background-position: initial initial; background-repeat: initial initial;"  ><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  >&nbsp;&nbsp;&nbsp; </span><b><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorblue=""  >while</span></b><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolordarkred=""  >(</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  >i</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;"  courier=""  newmso-fareast-font-familycolordarkred=""  >&lt;</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  >la</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;"  courier=""  newmso-fareast-font-familycolordarkred=""  >)</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorred=""  >{</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  ></span></p>  <p style="font-family: 微软雅黑, 黑体, Verdana; margin-bottom: 0.0001pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; background-position: initial initial; background-repeat: initial initial;"  ><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><b><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorblue=""  >if</span></b><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolordarkred=""  >(</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  >j</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;"  courier=""  newmso-fareast-font-familycolordarkred=""  >==-</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorpurple=""  >1</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  > </span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;"  courier=""  newmso-fareast-font-familycolordarkred=""  >||</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  > a</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;"  courier=""  newmso-fareast-font-familycolordarkred=""  >[</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  >i</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;"  courier=""  newmso-fareast-font-familycolordarkred=""  >]==</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  >a</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;"  courier=""  newmso-fareast-font-familycolordarkred=""  >[</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  >j</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;"  courier=""  newmso-fareast-font-familycolordarkred=""  >])</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorred=""  >{</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  ></span></p>  <p style="font-family: 微软雅黑, 黑体, Verdana; margin-bottom: 0.0001pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; background-position: initial initial; background-repeat: initial initial;"  ><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolordarkred=""  >++,</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  >j</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;"  courier=""  newmso-fareast-font-familycolordarkred=""  >++;</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  >&nbsp;</span></p>  <p style="font-family: 微软雅黑, 黑体, Verdana; margin-bottom: 0.0001pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; background-position: initial initial; background-repeat: initial initial;"  ><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //next</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolordarkred=""  >[</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  >i</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;"  courier=""  newmso-fareast-font-familycolordarkred=""  >]=</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  >j</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;"  courier=""  newmso-fareast-font-familycolordarkred=""  >; </span><span style="font-size:13.5pt;mso-bidi-font-size:11.0pt;font-family:宋体;mso-ascii-font-family: ;"  courier=""  newmso-hansi-font-familycourier=""  newmso-bidi-font-familycourier=""  new=""  colordarkred=""  >这里可以改进</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  ></span></p>  <p style="font-family: 微软雅黑, 黑体, Verdana; margin-bottom: 0.0001pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; background-position: initial initial; background-repeat: initial initial;"  ><b><span lang="EN-US"  style="font-size:12.0pt;"  courier=""  newmso-fareast-font-family=""  colorblue=""  >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if</span></b><span lang="EN-US"  style="font-size:12.0pt;"  courier=""  newmso-fareast-font-family=""  colordarkred=""  >(</span><span lang="EN-US"  style="font-size: 12pt; font-family: 'Courier New';"  >a</span><span lang="EN-US"  style="font-size:12.0pt;"  courier=""  newmso-fareast-font-family=""  colordarkred=""  >[</span><span lang="EN-US"  style="font-size: 12pt; font-family: 'Courier New';"  >i</span><span lang="EN-US"  style="font-size:12.0pt;"  courier=""  newmso-fareast-font-family=""  colordarkred=""  >]==</span><span lang="EN-US"  style="font-size: 12pt; font-family: 'Courier New';"  >a</span><span lang="EN-US"  style="font-size:12.0pt;"  courier=""  newmso-fareast-font-family=""  colordarkred=""  >[</span><span lang="EN-US"  style="font-size: 12pt; font-family: 'Courier New';"  >j</span><span lang="EN-US"  style="font-size:12.0pt;"  courier=""  newmso-fareast-font-family=""  colordarkred=""  >])</span><span lang="EN-US"  style="font-size: 12pt; font-family: 'Courier New';"  > next</span><span lang="EN-US"  style="font-size:12.0pt;"  courier=""  newmso-fareast-font-family=""  colordarkred=""  >[</span><span lang="EN-US"  style="font-size: 12pt; font-family: 'Courier New';"  >i</span><span lang="EN-US"  style="font-size:12.0pt;"  courier=""  newmso-fareast-font-family=""  colordarkred=""  >]=</span><span lang="EN-US"  style="font-size: 12pt; font-family: 'Courier New';"  >next</span><span lang="EN-US"  style="font-size:12.0pt;"  courier=""  newmso-fareast-font-family=""  colordarkred=""  >[</span><span lang="EN-US"  style="font-size: 12pt; font-family: 'Courier New';"  >j</span><span lang="EN-US"  style="font-size:12.0pt;"  courier=""  newmso-fareast-font-family=""  colordarkred=""  >];</span><span lang="EN-US"  style="font-size: 12pt; font-family: 'Courier New';"  ></span></p>  <p style="font-family: 微软雅黑, 黑体, Verdana; margin-bottom: 0.0001pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; background-position: initial initial; background-repeat: initial initial;"  ><span lang="EN-US"  style="font-size: 12pt; font-family: 'Courier New';"  >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;</span><b><span lang="EN-US"  style="font-size:12.0pt;"  courier=""  newmso-fareast-font-family=""  colorblue=""  >else</span></b><span lang="EN-US"  style="font-size: 12pt; font-family: 'Courier New';"  > next</span><span lang="EN-US"  style="font-size:12.0pt;"  courier=""  newmso-fareast-font-family=""  colordarkred=""  >[</span><span lang="EN-US"  style="font-size: 12pt; font-family: 'Courier New';"  >i</span><span lang="EN-US"  style="font-size:12.0pt;"  courier=""  newmso-fareast-font-family=""  colordarkred=""  >]=</span><span lang="EN-US"  style="font-size: 12pt; font-family: 'Courier New';"  >j</span><span lang="EN-US"  style="font-size:12.0pt;"  courier=""  newmso-fareast-font-family=""  colordarkred=""  >;</span><span lang="EN-US"  style="font-size: 12pt; font-family: 'Courier New';"  ></span></p>  <p style="font-family: 微软雅黑, 黑体, Verdana; margin-bottom: 0.0001pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; background-position: initial initial; background-repeat: initial initial;"  ><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorred=""  >}</span><b><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorblue=""  >else</span></b><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  > j</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;"  courier=""  newmso-fareast-font-familycolordarkred=""  >=</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  >next</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;"  courier=""  newmso-fareast-font-familycolordarkred=""  >[</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  >j</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;"  courier=""  newmso-fareast-font-familycolordarkred=""  >];</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  ></span></p>  <p style="font-family: 微软雅黑, 黑体, Verdana; margin-bottom: 0.0001pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; background-position: initial initial; background-repeat: initial initial;"  ><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  >&nbsp;&nbsp;&nbsp; </span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorred=""  >}</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  ></span></p>  <p style="font-family: 微软雅黑, 黑体, Verdana; margin-bottom: 0.0001pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; background-position: initial initial; background-repeat: initial initial;"  ><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorred=""  >}</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  ></span></p>  <p style="font-family: 微软雅黑, 黑体, Verdana; margin-bottom: 0.0001pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; background-position: initial initial; background-repeat: initial initial;"  ><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolordarkgreen=""  >int</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  > </span><b><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  >kmp</span></b><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolordarkred=""  >()</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorred=""  >{</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  ></span></p>  <p style="font-family: 微软雅黑, 黑体, Verdana; margin-bottom: 0.0001pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; background-position: initial initial; background-repeat: initial initial;"  ><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolordarkgreen=""  >int</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  > i</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;"  courier=""  newmso-fareast-font-familycolordarkred=""  >=</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorpurple=""  >0</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolordarkred=""  >,</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  >j</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;"  courier=""  newmso-fareast-font-familycolordarkred=""  >=</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorpurple=""  >0</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolordarkred=""  >,</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  >cnt</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;"  courier=""  newmso-fareast-font-familycolordarkred=""  >=</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorpurple=""  >0</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolordarkred=""  >;</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  ></span></p>  <p style="font-family: 微软雅黑, 黑体, Verdana; margin-bottom: 0.0001pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; background-position: initial initial; background-repeat: initial initial;"  ><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  >&nbsp;&nbsp;&nbsp; </span><b><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorblue=""  >while</span></b><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolordarkred=""  >(</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  >i</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;"  courier=""  newmso-fareast-font-familycolordarkred=""  >&lt;</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  >lb</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;"  courier=""  newmso-fareast-font-familycolordarkred=""  >)</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorred=""  >{</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  ></span></p>  <p style="font-family: 微软雅黑, 黑体, Verdana; margin-bottom: 0.0001pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; background-position: initial initial; background-repeat: initial initial;"  ><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><b><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorblue=""  >if</span></b><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolordarkred=""  >(</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  >j</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;"  courier=""  newmso-fareast-font-familycolordarkred=""  >==-</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorpurple=""  >1</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  > </span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;"  courier=""  newmso-fareast-font-familycolordarkred=""  >||</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  > b</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;"  courier=""  newmso-fareast-font-familycolordarkred=""  >[</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  >i</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;"  courier=""  newmso-fareast-font-familycolordarkred=""  >]==</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  >a</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;"  courier=""  newmso-fareast-font-familycolordarkred=""  >[</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  >j</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;"  courier=""  newmso-fareast-font-familycolordarkred=""  >])</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorred=""  >{</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  ></span></p>  <p style="font-family: 微软雅黑, 黑体, Verdana; margin-bottom: 0.0001pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; background-position: initial initial; background-repeat: initial initial;"  ><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolordarkred=""  >++,</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  >j</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;"  courier=""  newmso-fareast-font-familycolordarkred=""  >++;</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  ></span></p>  <p style="font-family: 微软雅黑, 黑体, Verdana; margin-bottom: 0.0001pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; background-position: initial initial; background-repeat: initial initial;"  ><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><b><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorblue=""  >if</span></b><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolordarkred=""  >(</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  >j</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;"  courier=""  newmso-fareast-font-familycolordarkred=""  >==</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  >la</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;"  courier=""  newmso-fareast-font-familycolordarkred=""  >)</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  > return 1;</span></p>  <p style="font-family: 微软雅黑, 黑体, Verdana; margin-bottom: 0.0001pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; background-position: initial initial; background-repeat: initial initial;"  ><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorred=""  >}</span><b><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorblue=""  >else</span></b><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  > j</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;"  courier=""  newmso-fareast-font-familycolordarkred=""  >=</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  >next</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;"  courier=""  newmso-fareast-font-familycolordarkred=""  >[</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  >j</span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size: 11.0pt;"  courier=""  newmso-fareast-font-familycolordarkred=""  >];</span><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  ></span></p>  <p style="font-family: 微软雅黑, 黑体, Verdana; margin-bottom: 0.0001pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; background-position: initial initial; background-repeat: initial initial;"  ><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  >&nbsp;&nbsp;&nbsp; </span><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorred=""  >}</span><b><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorblue=""  >return</span></b><span lang="EN-US"  style="font-size: 13.5pt; font-family: 'Courier New';"  > 0;</span></p>  <p style="font-family: 微软雅黑, 黑体, Verdana; margin-bottom: 0.0001pt; line-height: 18.75pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; background-position: initial initial; background-repeat: initial initial;"  ><span lang="EN-US"  style="font-size:13.5pt;mso-bidi-font-size:11.0pt;"  courier=""  new=""  mso-fareast-font-familycolorred=""  >}</span></p></h1></div>]]></description>
	    <author><![CDATA[long1]]></author>
	    <comments>http://blog.163.com/lfw2565295@126/blog/static/12200516201239111536401</comments>
    <slash:comments>1</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/lfw2565295@126/blog/static/12200516201239111536401</guid>
    <pubDate>Mon, 9 Apr 2012 11:19:19 +0800</pubDate>
    <dcterms:modified>2012-04-09T11:24:44+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[特殊矩阵 数据结构里的特殊矩阵及其存储]]></title>	
    <link>http://blog.163.com/lfw2565295@126/blog/static/1220051620123843327688</link>
    <description><![CDATA[<div><p style="font-family: Tahoma, Verdana, Arial; font-size: 12px; text-align: -webkit-auto; background-color: rgb(255, 255, 238); line-height: 18px;"  ><strong><font size="4"  >特殊矩阵&nbsp;</font></strong><font color="#008000"  size="4"  ><br></font><br>&nbsp;&nbsp;&nbsp; 　所谓特殊矩阵是指非零元素或零元素的分布有一定规律的矩阵。常见的有对称矩阵、三角矩阵和对角矩阵等。<br><strong>1．对称矩阵</strong><br><font color="#0000ff"  >（1）对称矩阵</font><br>&nbsp;&nbsp;&nbsp; 　在一个n阶方阵A中，若元素满足下述性质：&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a<sub>ij</sub>=a<sub>ji</sub>&nbsp;0≤i，j≤n-1<br>则称A为对称矩阵。<br>【例】下图便是一个5阶对称矩阵。<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img title="特殊矩阵 数据结构里的特殊矩阵及其存储 - long1 - long1 vs longpo"  height="168"  alt=""  src="http://node3.foto.ycstatic.com/200603/03/8/9594568.jpg"  width="178"  border="0"  ></p><p align="left"  style="font-family: Tahoma, Verdana, Arial; font-size: 12px; background-color: rgb(255, 255, 238); line-height: 18px;"  ><font color="#0000ff"  >（2）对称矩阵的压缩存储</font><br>&nbsp;&nbsp;&nbsp; 对称矩阵中的元素关于主对角线对称，故只要存储矩阵中上三角或下三角中的元素，让每两个对称的元素共享一个存储空间。这样，能节约近一半的存储空间。<br><strong>①按"行优先顺序"存储主对角线(包括对角线)以下的元素</strong>&nbsp;<font color="#ff00ff"  ><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><img title="特殊矩阵 数据结构里的特殊矩阵及其存储 - long1 - long1 vs longpo"  height="149"  alt=""  src="http://node3.foto.ycstatic.com/200603/03/5/9594533.jpg"  width="216"  border="0"  ><br>&nbsp;&nbsp;&nbsp; 即按a<sub>00</sub>,a<sub>10</sub>,a<sub>11</sub>,……，a<sub>n-1,0</sub>,a<sub>n-1,1</sub>…，a<sub>n-1,n-1</sub>次序存放在一个向量sa[0．．n(n+1)／2-1]中（下三角矩阵中，元素总数为n(n+1)／2）。<br>&nbsp;&nbsp;&nbsp; 其中：<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sa[0]= a<sub>00</sub>&nbsp;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sa[1] = a<sub>10</sub>&nbsp;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ……，<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sa[n(n+1)／2-1]= a<sub>n-1,n-1</sub><br><strong>②元素a<sub>ij</sub>的存放位置</strong><br>&nbsp;&nbsp;&nbsp; a<sub>ij</sub>元素前有i行(从第0行到第i-1行)，一共有：<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1+2+…+i=i×(i+1)／2个元素；<br>&nbsp;&nbsp;&nbsp; 在第i行上，aij之前恰有j个元素(即a<sub>i0</sub>，a<sub>il</sub>，…，a<sub>i,j-1</sub>)，因此有：<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sa[i×(i+1)／2+j]= a<sub>ij&nbsp;</sub><br><strong>③a<sub>ij</sub>和sa[k]之间的对应关系：</strong><br>&nbsp;&nbsp;&nbsp; 若i≥j，k=i×(i+1)／2+j&nbsp;&nbsp; 0≤k&lt;n(n+1)／2<br>&nbsp;&nbsp;&nbsp; 若i＜j，k=j×(j+1)／2+i&nbsp;&nbsp; 0≤k&lt;n(n+1)／2<br>&nbsp;&nbsp;&nbsp; 令I=max(i，j)，J=min(i，j)，则k和i，j的对应关系可统一为：<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; k=I×(I+1)／2+J 0≤k&lt;n(n+1)／2&nbsp;<br><br><font color="#0000ff"  >（3）对称矩阵的地址计算公式</font><br>&nbsp; LOC(a<sub>ij</sub>)=LOC(sa[k])<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =LOC(sa[0])+k×d=LOC(sa[0])+[I×(I+1)／2+J]×d<br>&nbsp;&nbsp;&nbsp; 通过下标变换公式，能立即找到矩阵元素a<sub>ij</sub>在其压缩存储表示sa中的对应位置k。因此是随机存取结构。<br>&nbsp; 【例】a<sub>21</sub>和a<sub>12</sub>均存储在sa[4]中，这是因为<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; k=I×(I+1)／2+J=2×(2+1)／2+1=4<br><br><br><br><br></p><center style="font-family: Tahoma, Verdana, Arial; font-size: 12px; line-height: normal; background-color: rgb(255, 255, 238);"  ><p align="right"  style="font-size: 9pt; line-height: 18px;"  ><font color="#ff0000"  ></font></p></center><p align="left"  style="font-family: Tahoma, Verdana, Arial; font-size: 12px; background-color: rgb(255, 255, 238); line-height: 18px;"  ><strong>2、三角矩阵</strong><font color="#ff0000"  >&nbsp;&nbsp;</font><br><font color="#0000ff"  >（1）三角矩阵的划分</font><br>&nbsp;&nbsp;&nbsp; 　以主对角线划分，三角矩阵有上三角矩阵和下三角矩阵两种。<br>①上三角矩阵<br>&nbsp;&nbsp;&nbsp; 　如下图(a)所示，它的下三角(不包括主角线)中的元素均为常数c。<br>②下三角矩阵<br>&nbsp;&nbsp;&nbsp; 　与上三角矩阵相反，它的主对角线上方均为常数c，如下图(b)所示。<br>&nbsp;&nbsp;<font color="#ff0000"  >注意：</font><br>　&nbsp;&nbsp;&nbsp; 在多数情况下，三角矩阵的常数c为零。<br><br>　　　<img title="特殊矩阵 数据结构里的特殊矩阵及其存储 - long1 - long1 vs longpo"  height="148"  alt=""  src="http://node0.foto.ycstatic.com/200603/03/0/9594176.jpg"  width="429"  border="0"  ><br><br><font color="#0000ff"  >（2）三角矩阵的压缩存储</font><br>&nbsp;&nbsp;&nbsp; 三角矩阵中的重复元素c可共享一个存储空间，其余的元素正好有n×(n+1)／2个，因此，三角矩阵可压缩存储到向量sa[0．．n(n+1)／2]中，其中c存放在向量的最后一个分量中。<br>&nbsp;&nbsp;&nbsp;<strong><br>① 上三角矩阵中a<sub>ij</sub>和sa[k]之间的对应关系</strong><br>&nbsp;&nbsp;&nbsp; 　上三角矩阵中，主对角线之上的第p行(0≤p&lt;n)恰有n-p个元素，按行优先顺序存放上三角矩阵中的元素a<sub>ij</sub>时：<br>&nbsp;&nbsp;&nbsp;&nbsp; a<sub>ij</sub>元素前有i行(从第0行到第i-1行)，一共有：<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (n-0)+(n-1)+(n-2)+…+(n-i)=i×(2n-i+1)／2个元素；<br>&nbsp;&nbsp;&nbsp; 　在第i行上，a<sub>ij</sub>之前恰有j-i个元素(即a<sub>ij</sub>，a<sub>i,j+l</sub>，…，a<sub>i,j-1</sub>)，因此有：<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sa[i×(2n-i+1)／2+j-i]= a<sub>ij</sub>&nbsp;<br>所以：<br>&nbsp; &nbsp;　&nbsp;┌i×(2n-i+1)／2+j-i 当i≤j<br>&nbsp;&nbsp;　k=│<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; └n×(n+1)/2 当i＞j<br><br><strong>②下三角矩阵中a<sub>ij</sub>和sa[k]之间的对应关系</strong><br>&nbsp;&nbsp;　 &nbsp; ┌i×(i+1)／2+j 当i≥j<br>　&nbsp;&nbsp; k=│<br>&nbsp;&nbsp;&nbsp; 　 └n×(n+1)/2 当i＜j<br><br><font color="#ff0000"  >&nbsp; 注意：<br>&nbsp;&nbsp;&nbsp; 　</font>三角矩阵的压缩存储结构是随机存取结构。<br><br><strong>3．对角矩阵</strong>&nbsp;<font color="#ff0000"  ><br>&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#ff0000"  >　</font>所有的非零元素集中在以主对角线为中心的带状区域中，即除了主对角线和主对角线相邻两侧的若干条对角线上的元素之外，其余元素皆为零的矩阵为对角矩阵。<br>　　【例】下图给出了一个三对角矩阵。<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img title="特殊矩阵 数据结构里的特殊矩阵及其存储 - long1 - long1 vs longpo"  height="162"  alt=""  src="http://node3.foto.ycstatic.com/200603/03/2/9594274.jpg"  width="275"  border="0"  ><br>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00ff00"  >&nbsp;</font>其中：<font color="#ff0000"  ><br>&nbsp;&nbsp;&nbsp;&nbsp;</font>非零元素仅出现在主对角上(a<sub>ii</sub>，0≤i≤n-1)，紧邻主对角线上面的那条对角线上(a<sub>i</sub><sub>，</sub><sub>i+1</sub>&nbsp;，0≤i≤n-2)和紧邻主对角线下面的那条对角线上(a&nbsp;<sub>i+1</sub><sub>，</sub><sub>i</sub>，0≤i≤n-2)。当|i-j|&gt;1时，元素a<sub>ij</sub>=0。<br>&nbsp;&nbsp;&nbsp; 　由此可知，一个k对角线矩阵(k为奇数)A是满足下述条件的矩阵：<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 若|i-j|&gt;(k-1)／2，则元素a<sub>ij</sub>=0。<br>&nbsp;&nbsp;&nbsp; 　对角矩阵可按行优先顺序或对角线的顺序，将其压缩存储到一个向量中，并且也能找到每个非零元素和向量下标的对应关系。</p><p align="left"  style="font-family: Tahoma, Verdana, Arial; font-size: 12px; background-color: rgb(255, 255, 238); line-height: 18px;"  ><br></p><p align="left"  style="font-family: Tahoma, Verdana, Arial; font-size: 12px; background-color: rgb(255, 255, 238); line-height: 18px;"  >转自：<a rel="nofollow" href="http://linjianren.ycool.com/post.1123606.html"  >http://linjianren.ycool.com/post.1123606.html</a></p><p align="left"  style="font-family: Tahoma, Verdana, Arial; font-size: 12px; background-color: rgb(255, 255, 238); line-height: 18px;"  ><br></p><wbr></div>]]></description>
	    <author><![CDATA[long1]]></author>
	    <comments>http://blog.163.com/lfw2565295@126/blog/static/1220051620123843327688</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/lfw2565295@126/blog/static/1220051620123843327688</guid>
    <pubDate>Sun, 8 Apr 2012 16:33:27 +0800</pubDate>
    <dcterms:modified>2012-04-08T16:33:27+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[实现b[i]=a[0]*a[1]*…a[N-1]/a[i] 不使用除法操作]]></title>	
    <link>http://blog.163.com/lfw2565295@126/blog/static/1220051620123822219731</link>
    <description><![CDATA[<div><div><b><font color="#0000ff"  size="4"  >/*</font></b></div><div><b><font color="#0000ff"  size="4"  >实现b[i]=a[0]*a[1]*…a[N-1]/a[i]</font></b></div><div><b><font color="#0000ff"  size="4"  >不使用除法操作，复杂度O(n),除了循环控制的i,数组a,b,不能使用其他变量&nbsp;</font></b></div><div><b><font color="#0000ff"  size="4"  >方法：</font></b></div><div><b><font color="#0000ff"  size="4"  >初始b[i]记录a[i+1~n-1]的积,a[i]记录a[0~i-1]的积</font></b></div><div><b><font color="#0000ff"  size="4"  >再一趟循环，计算b[i]=a[i-1]*b[i+1]</font></b></div><div><b><font color="#0000ff"  size="4"  >复杂度：O(n)，额外数据空间：无&nbsp;</font></b></div><div><b><font color="#0000ff"  size="4"  >*/</font></b></div><div>#include&lt;iostream&gt;</div><div>#include&lt;cstdio&gt;</div><div>#include&lt;cstring&gt;</div><div>using namespace std;</div><div>#define N 5</div><div>int main(){</div><div>&nbsp; &nbsp; int a[N]={1,2,3,4,5};</div><div>&nbsp; &nbsp; int b[N];</div><div>&nbsp; &nbsp; for(int i=N-1; i&gt;0; i--) {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; b[i]=a[i];</div><div>&nbsp; &nbsp; &nbsp; &nbsp; if(i&lt;N-1) b[i]*=b[i+1];</div><div>&nbsp; &nbsp; }</div><div>&nbsp; &nbsp; for(int i=1; i&lt;N-1; i++){</div><div>&nbsp; &nbsp; &nbsp; &nbsp; a[i]*=a[i-1];</div><div>&nbsp; &nbsp; }</div><div>&nbsp; &nbsp; for(int i=0; i&lt;N; i++){</div><div>&nbsp; &nbsp; &nbsp; &nbsp; if(i==0) b[i]=b[i+1];</div><div>&nbsp; &nbsp; &nbsp; &nbsp; else if(i==N-1 &amp;&amp; i-1&gt;=0) b[i]=a[i-1];</div><div>&nbsp; &nbsp; &nbsp; &nbsp; else b[i]=a[i-1]*b[i+1];</div><div>&nbsp; &nbsp; }</div><div>&nbsp; &nbsp; for(int i=0; i&lt;N; i++){</div><div>&nbsp; &nbsp; &nbsp; &nbsp; printf("%d ",b[i]);</div><div>&nbsp; &nbsp; }</div><div>&nbsp; &nbsp; puts("");</div><div>&nbsp; &nbsp; system("pause");</div><div>}</div><wbr></div>]]></description>
	    <author><![CDATA[long1]]></author>
	    <comments>http://blog.163.com/lfw2565295@126/blog/static/1220051620123822219731</comments>
    <slash:comments>1</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/lfw2565295@126/blog/static/1220051620123822219731</guid>
    <pubDate>Sun, 8 Apr 2012 14:22:19 +0800</pubDate>
    <dcterms:modified>2012-04-08T14:22:19+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[清明回家归来]]></title>	
    <link>http://blog.163.com/lfw2565295@126/blog/static/1220051620123555129507</link>
    <description><![CDATA[<div><b><font color="#0000ff"  size="4"  >简述一下回家2天的经历</font></b><div><b><font color="#0000ff"  size="4"  >其实没什么经历，首先想有机会多见见爸爸妈妈，姐姐去厦门旅游了，没见到</font></b></div><div><b><font color="#0000ff"  size="4"  >其次自大学5年多来，我还真没主动回家，尤其清明，有两次清明去杭州玩了</font></b></div><div><b><font color="#0000ff"  size="4"  >4.4清明的日子很神奇，上一天，后一天的天气都是阳光明媚，就是清明的日子有点小雨，应验清明时节雨纷纷的情景</font></b></div><div><b><font color="#0000ff"  size="4"  >各个坟都去上了下，摆水果，点蜡烛，放烟火，捧一把泥到坟头</font></b></div><div><b><font color="#0000ff"  size="4"  >然后和亲戚们聊聊马上快毕业了，就业方向什么的，有说找稳定点的事业单位，教师，公务员，也有推荐去大城市闯的，但这些都是意见</font></b></div><div><b><font color="#0000ff"  size="4"  >身体依旧不是很好，貌似类似感冒，喉咙痛这些病我都得持续一个月左右</font></b></div><div><b><font color="#0000ff"  size="4"  >不过重要的是，回家和爸爸妈妈聊聊，问问他们的近况，一起吃吃饭，这样就挺好了</font></b></div><div><b><font color="#0000ff"  size="4"  >常回家看看！</font></b></div><div><br><wbr></div><div><img title="清明回家归来 - long1 - long1 vs longpo"  alt="清明回家归来 - long1 - long1 vs longpo"  style="margin:0 10px 0 0;"  src="http://img0.ph.126.net/jXuoT1saCx_kJH4sc7hZtw==/590253026179623500.jpg"  ></div></div>]]></description>
	    <author><![CDATA[long1]]></author>
	    <comments>http://blog.163.com/lfw2565295@126/blog/static/1220051620123555129507</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/lfw2565295@126/blog/static/1220051620123555129507</guid>
    <pubDate>Thu, 5 Apr 2012 17:52:05 +0800</pubDate>
    <dcterms:modified>2012-04-05T18:01:44+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[我今年二十七八岁]]></title>	
    <link>http://blog.163.com/lfw2565295@126/blog/static/12200516201232864267</link>
    <description><![CDATA[<div><div><font size="4"  color="#0000ff"  >我今年二十七八岁，</font></div><div><font size="4"  color="#0000ff"  >　　每天起床的时间从中午12点变成了早上7点，睡觉的时间从凌晨变成了晚上11点。</font></div><div><font size="4"  color="#0000ff"  >　　我今年二十七八岁，</font></div><div><font size="4"  color="#0000ff"  >　　工作中开始接触形形色色的人，</font></div><div><font size="4"  color="#0000ff"  >　　我今年二十七八岁，</font></div><div><font size="4"  color="#0000ff"  >　　见到亲戚朋友，他们不再问你考试考了几分，更多的是问现在一个月工资是多少，结婚没有哇...</font></div><div><font size="4"  color="#0000ff"  >　　我今年二十七八岁，</font></div><div><font size="4"  color="#0000ff"  >　　聊天的话题从各种网络游戏变成汽车，房子…</font></div><div><font size="4"  color="#0000ff"  >　　吃饭的时候，讨论的往往是他准备结婚，她哪年结婚了…</font></div><div><font size="4"  color="#0000ff"  >　　我今年二十七八岁，</font></div><div><font size="4"  color="#0000ff"  >　　每天不再感叹学校作业有多少作业做不完，开始感叹油价，房价涨得有多快，股票是涨还是跌…</font></div><div><font size="4"  color="#0000ff"  >　　我今年二十七八岁，</font></div><div><font size="4"  color="#0000ff"  >　　不再乱买东西，月底开始算计，这个月还了信用卡，开销多少，还剩下多少，该开始攒钱买房子了…</font></div><div><font size="4"  color="#0000ff"  >　　我今年二十七八岁，</font></div><div><font size="4"  color="#0000ff"  >　　渐渐的讨厌酒吧、KTV，喜欢亲近自然，喜欢健康的生活方式…</font></div><div><font size="4"  color="#0000ff"  >　　我今年二十七八岁，</font></div><div><font size="4"  color="#0000ff"  >　　偶尔会有寂寞，偶尔会怀念一个人；</font></div><div><font size="4"  color="#0000ff"  >　　我今年二十七八岁，</font></div><div><font size="4"  color="#0000ff"  >　　我们开始追逐梦想，不会再轻易流泪，不会再为了一点挫折而放弃…</font></div><div><font size="4"  color="#0000ff"  >　　我今年二十七八岁，</font></div><div><font size="4"  color="#0000ff"  >　　没有了年少的轻狂，把遇到的挫折困难都当作一种人生的阅历，试着去包容试着去忍耐…</font></div><div><font size="4"  color="#0000ff"  >　　我今年二十七八岁，</font></div><div><font size="4"  color="#0000ff"  >　　回想起曾经，我们做了太多的错事，走了太多的弯路 ，我们总在后悔，可是我们回不去了，回不去那个曾经纯真的年代了。</font></div><div><font size="4"  color="#0000ff"  >　　当我们被社会上无形的压力压得喘不过气的时候，我们渴望曾经的那份爱，渴望每天下班能有一个人一起吃饭，一起看电影，我们需要有一个人，来为我们分担一些东西。</font></div><div><font size="4"  color="#0000ff"  >　　我们在一条伟大的航路上，我们需要有人为我们鼓劲，也许我们偶尔累倒想放弃，可是当我们想到身边还有个让我们挂念的一个人，深吸一口气，继续向前走，我相信，总有一个能够停靠的彼岸。</font></div><div><font size="4"  color="#0000ff"  >　　我今年二十七八岁，</font></div><div><font size="4"  color="#0000ff"  >　　孤单时我们没有去网吧，我们用手机隐身上QQ，看看谁在线呢，看见熟悉的人，想说点什么，究竟又什么也没说，就这样纠结着…</font></div><div><font size="4"  color="#0000ff"  >　　我们把空间刷新了一遍又一遍，看看谁更新了心情，谁更新了日志，回复了符号，却没有回复句子…</font></div><div><font size="4"  color="#0000ff"  >　　我今年二十七八岁，</font></div><div><font size="4"  color="#0000ff"  >　　烦恼的时候不再发牢骚，我们静静的，静静的看着、听着，这很现实又很虚伪的世界…</font></div><div><font size="4"  color="#0000ff"  >　　我今年二十七八岁，</font></div><div><font size="4"  color="#0000ff"  >　　明明很想哭，却还在笑；</font></div><div><font size="4"  color="#0000ff"  >　　明明很在乎，却装作无所谓；</font></div><div><font size="4"  color="#0000ff"  >　　明明很想留下，却坚定地说要离开；</font></div><div><font size="4"  color="#0000ff"  >　　明明很痛苦，却偏偏说自己很幸福；</font></div><div><font size="4"  color="#0000ff"  >　　明明忘不掉，却说已经忘了；</font></div><div><font size="4"  color="#0000ff"  >　　明明放不下，却说她是她，我是我；</font></div><div><font size="4"  color="#0000ff"  >　　明明舍不得，却说我已经受够了；</font></div><div><font size="4"  color="#0000ff"  >　　明明说的是违心的假话，却说那是自己的真心话；</font></div><div><font size="4"  color="#0000ff"  >　　明明眼泪都快溢出眼眶，却高昂着头；</font></div><div><font size="4"  color="#0000ff"  >　　明明已经无法挽回，却依旧执着；</font></div><div><font size="4"  color="#0000ff"  >　　明明知道自己很受伤，却说你不必觉得欠我的；</font></div><div><font size="4"  color="#0000ff"  >　　明明这样『伪装』得很累，却还得依旧…</font></div><div><font size="4"  color="#0000ff"  >　　为得只是隐藏自己的脆弱，即使很难过，也会装的无所谓…</font></div><div><font size="4"  color="#0000ff"  >　　只是不愿别人看见自己的伤口，不让自己周围的人担心，不想别人同情自己…</font></div><div><font size="4"  color="#0000ff"  >　　只想在心底独自承受，虽然心疼的难以呼吸，却笑着告诉所有人“我没事的！”然后静下来时，自己便笑话自己，何必把自己伪装得这么坚强？好像自己可以承受所有的苦难…</font></div><div><font size="4"  color="#0000ff"  >　　呵…这好累，好累！！！</font></div><div><br></div><div>http://www.tudou.com/programs/view/nAFa6ESjDHg/?fr=rec1&amp;FR=LIAN</div><div><br></div><wbr></div>]]></description>
	    <author><![CDATA[long1]]></author>
	    <comments>http://blog.163.com/lfw2565295@126/blog/static/12200516201232864267</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/lfw2565295@126/blog/static/12200516201232864267</guid>
    <pubDate>Mon, 2 Apr 2012 20:06:42 +0800</pubDate>
    <dcterms:modified>2012-04-02T20:06:42+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[CSS 初步 http://www.w3school.com.cn/]]></title>	
    <link>http://blog.163.com/lfw2565295@126/blog/static/1220051620123234439612</link>
    <description><![CDATA[<div><font size="4"  color="#333399"  ><div><span style="font-weight: 800;"  >&nbsp;http://www.w3school.com.cn/</span></div><div><span style="font-weight: 800;"  ><br></span></div><b>jsp页面里增加</b><wbr></font><div><font size="4"  color="#333399"  ><b>&lt;link href="css/style.css" rel="stylesheet" type="text/css"&gt;</b></font></div><div><font size="4"  color="#333399"  ><b>连接到css文件夹下的style.css文件，然后样式就会按照里面的内容变化了</b></font></div><div><br></div><div>看看例子：</div><div>http://www.w3school.com.cn/tiy/t.asp?f=csse_background-color</div><div><br></div><div>代码：</div><div><div>&lt;html&gt;</div><div>&lt;head&gt;</div><div><br></div><div>&lt;style type="text/css"&gt;</div><div><br></div><div>body {background-color: yellow}</div><div>h1 {background-color: #00ff00}</div><div>h2 {background-color: transparent}</div><div>p {background-color: rgb(250,0,255)}</div><div>.white {</div><div><span style="white-space:pre;"  > </span>font-size: 20pt; color: #FFFFFF; font-family:"宋体";</div><div>}</div><div>p.no2 {background-color: gray; padding: 20px;}</div><div><br></div><div>&lt;/style&gt;</div><div><br></div><div>&lt;/head&gt;</div><div><br></div><div>&lt;body&gt;</div><div><br></div><div>&lt;h1&gt;这是标题 1&lt;/h1&gt;</div><div>&lt;h2&gt;这是标题 2&lt;/h2&gt;</div><div>&lt;p&gt;这是段落&lt;/p&gt;</div><div>&lt;p class="no2"&gt;这个段落设置了内边距。&lt;/p&gt;</div><div>&lt;p class="white"&gt;看看class的效果&lt;/p&gt;</div><div>&lt;/body&gt;</div><div>&lt;/html&gt;</div></div><div><br></div><div>显示：</div><div><div><img title="CSS 初步 http://www.w3school.com.cn/ - long1 - long1 vs longpo"  alt="CSS 初步 http://www.w3school.com.cn/ - long1 - long1 vs longpo"  style="margin:0 10px 0 0;"  src="http://img5.ph.126.net/tqbH-O0pF2euDglE_IvvCQ==/591378926086457605.jpg"  ></div><div><div style="layout-grid:15.6000pt;"  ><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-size:10.5000pt; font-family:'宋体';"  >关于背景的例子：&nbsp;<font face="Times New Roman"  >(</font><font face="宋体"  >也可以一个声明中</font></span><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-size:10.5000pt; font-family:'宋体';"  >background:&nbsp;#ff0000&nbsp;url(/i/eg_bg_03.gif)&nbsp;no-repeat&nbsp;fixed&nbsp;center;&nbsp;)</span><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&lt;html&gt;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&lt;head&gt;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&lt;style&nbsp;type="text/css"&gt;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >body</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >{&nbsp;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&nbsp;background-image:url('/i/eg_bg_03.gif');</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&nbsp;background-repeat:no-repeat;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&nbsp;background-attachment:fixed;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&nbsp;background-position:center;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >}</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&lt;/style&gt;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&lt;/head&gt;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&lt;body&gt;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&lt;body&gt;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&lt;p&gt;&lt;b&gt;<font face="宋体"  >提示：</font><font face="Times New Roman"  >&lt;/b&gt;</font><font face="宋体"  >您需要把&nbsp;</font><font face="Times New Roman"  >background-attachment&nbsp;</font><font face="宋体"  >属性设置为&nbsp;</font><font face="Times New Roman"  >"fixed"</font><font face="宋体"  >，才能保证该属性在&nbsp;</font><font face="Times New Roman"  >Firefox&nbsp;</font><font face="宋体"  >和&nbsp;</font><font face="Times New Roman"  >Opera&nbsp;</font><font face="宋体"  >中正常工作。</font><font face="Times New Roman"  >&lt;/p&gt;</font></span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&lt;/body&gt;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&lt;/body&gt;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&lt;/html&gt;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-size:10.5000pt; font-family:'宋体';"  >显示：</span><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ></p><div><img title="CSS 初步 http://www.w3school.com.cn/ - long1 - long1 vs longpo"  alt="CSS 初步 http://www.w3school.com.cn/ - long1 - long1 vs longpo"  style="margin:0 10px 0 0;"  src="http://img4.ph.126.net/lbDB_rTlbz3FHhQ_dXiinw==/2633198407145560134.jpg"  ></div>&nbsp;<p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-size:10.5000pt; font-family:'宋体';"  >设置表单的样式：</span><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&lt;!DOCTYPE&nbsp;html&nbsp;PUBLIC&nbsp;"-//W3C//DTD&nbsp;XHTML&nbsp;1.0&nbsp;Transitional//EN"&nbsp;"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&lt;html&gt;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&lt;head&gt;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&lt;style&gt;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-size:10.5000pt; font-family:'宋体';"  >input[type="text"]</span><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >{</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&nbsp;width:150px;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&nbsp;display:block;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&nbsp;margin-bottom:10px;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&nbsp;background-color:yellow;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&nbsp;font-family:&nbsp;Verdana,&nbsp;Arial;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >}</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-size:10.5000pt; font-family:'宋体';"  >input[type="button"]</span><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >{</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&nbsp;width:120px;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&nbsp;margin-left:35px;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&nbsp;display:block;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&nbsp;font-family:&nbsp;Verdana,&nbsp;Arial;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >}</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&lt;/style&gt;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&lt;/head&gt;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&lt;body&gt;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&lt;form&nbsp;name="input"&nbsp;action=""&nbsp;method="get"&gt;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&lt;input&nbsp;type="text"&nbsp;name="Name"&nbsp;value="Bill"&nbsp;size="20"&gt;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&lt;input&nbsp;type="text"&nbsp;name="Name"&nbsp;value="Gates"&nbsp;size="20"&gt;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&lt;input&nbsp;type="button"&nbsp;value="Example&nbsp;Button"&gt;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&lt;/form&gt;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&lt;/body&gt;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&lt;/html&gt;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-size:10.5000pt; font-family:'宋体';"  >显示：</span><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ></p><div><img title="CSS 初步 http://www.w3school.com.cn/ - long1 - long1 vs longpo"  alt="CSS 初步 http://www.w3school.com.cn/ - long1 - long1 vs longpo"  style="margin:0 10px 0 0;"  src="http://img7.ph.126.net/wHx6EZ00yK5NtkSDyhtihw==/2732840548901124487.jpg"  ></div>&nbsp;<p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-size:10.5000pt; font-family:'宋体';"  >超链接，鼠标放上去的样子</span><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-size:10.5000pt; font-family:'宋体';"  >,a:hover<font face="宋体"  >例子：</font></span><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >a:hover&nbsp;{</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  > </span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >font-size:&nbsp;9pt;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  > </span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >color:#FF0000;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  > </span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >text-decoration:&nbsp;underline;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  > </span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >cursor:url("images/back/0081.ani");</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >}</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >a&nbsp;{</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  > </span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >font-size:&nbsp;9pt;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  > </span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >text-decoration:&nbsp;none;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  > </span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >color:#000000;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  > </span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >text-decoration:&nbsp;underline;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  > </span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >cursor:url("images/back/0081.ani");</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >}</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; text-align:left;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-style:normal; font-size:10.5000pt; font-family:'Verdana';"  >id&nbsp;<font face="宋体"  >选择器</font></span><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-style:normal; font-size:10.5000pt; font-family:'Verdana';"  ></span></p><p style="margin-bottom:0pt; margin-top:9.0000pt; text-autospace:ideograph-other; line-height:13.5000pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-size:10.5000pt; font-family:'Times New Roman';"  >id&nbsp;<font face="宋体"  >选择器可以为标有特定&nbsp;</font><font face="Times New Roman"  >id&nbsp;</font><font face="宋体"  >的&nbsp;</font><font face="Times New Roman"  >HTML&nbsp;</font><font face="宋体"  >元素指定特定的样式。</font></span><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-size:10.5000pt; font-family:'Times New Roman';"  ></span></p><p style="margin-bottom:0pt; margin-top:9.0000pt; text-autospace:ideograph-other; line-height:13.5000pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-size:10.5000pt; font-family:'Times New Roman';"  >id&nbsp;<font face="宋体"  >选择器以&nbsp;</font><font face="Times New Roman"  >"#"&nbsp;</font><font face="宋体"  >来定义。</font></span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  ></span></p><p style="margin-bottom:0pt; margin-top:9.0000pt; text-autospace:ideograph-other; line-height:13.5000pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  >下面的两个&nbsp;<font face="Times New Roman"  >id&nbsp;</font><font face="宋体"  >选择器，第一个可以定义元素的颜色为红色，第二个定义元素的颜色为绿色：</font></span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  ></span></p><p style="margin-bottom:0pt; margin-top:7.5000pt; border-top:0.7500pt dotted rgb(119,136,85); mso-border-top-alt:0.7500pt dotted rgb(119,136,85); border-right:0.7500pt dotted rgb(119,136,85); mso-border-right-alt:0.7500pt dotted rgb(119,136,85); border-bottom:0.7500pt dotted rgb(119,136,85); mso-border-bottom-alt:0.7500pt dotted rgb(119,136,85); border-left:0.7500pt dotted rgb(119,136,85); mso-border-left-alt:0.7500pt dotted rgb(119,136,85); padding:10pt 10pt 10pt 10pt ; text-autospace:ideograph-other;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-size:9.0000pt; font-family:'Courier New';"  >#red</span><span style="mso-spacerun:'yes'; font-size:9.0000pt; font-family:'Courier New';"  >&nbsp;{color:red;}</span><span style="mso-spacerun:'yes'; font-size:9.0000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:7.5000pt; border-top:0.7500pt dotted rgb(119,136,85); mso-border-top-alt:0.7500pt dotted rgb(119,136,85); border-right:0.7500pt dotted rgb(119,136,85); mso-border-right-alt:0.7500pt dotted rgb(119,136,85); border-bottom:0.7500pt dotted rgb(119,136,85); mso-border-bottom-alt:0.7500pt dotted rgb(119,136,85); border-left:0.7500pt dotted rgb(119,136,85); mso-border-left-alt:0.7500pt dotted rgb(119,136,85); padding:10pt 10pt 10pt 10pt ; text-autospace:ideograph-other;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-size:9.0000pt; font-family:'Courier New';"  >#green</span><span style="mso-spacerun:'yes'; font-size:9.0000pt; font-family:'Courier New';"  >&nbsp;{color:green;}</span><span style="mso-spacerun:'yes'; font-size:9.0000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:9.0000pt; text-autospace:ideograph-other; line-height:13.5000pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  >下面的&nbsp;<font face="Times New Roman"  >HTML&nbsp;</font><font face="宋体"  >代码中，</font><font face="Times New Roman"  >id&nbsp;</font><font face="宋体"  >属性为&nbsp;</font><font face="Times New Roman"  >red&nbsp;</font><font face="宋体"  >的&nbsp;</font><font face="Times New Roman"  >p&nbsp;</font><font face="宋体"  >元素显示为红色，而&nbsp;</font><font face="Times New Roman"  >id&nbsp;</font><font face="宋体"  >属性为&nbsp;</font><font face="Times New Roman"  >green&nbsp;</font><font face="宋体"  >的&nbsp;</font><font face="Times New Roman"  >p&nbsp;</font><font face="宋体"  >元素显示为绿色。</font></span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  ></span></p><p style="margin-bottom:0pt; margin-top:7.5000pt; border-top:0.7500pt dotted rgb(119,136,85); mso-border-top-alt:0.7500pt dotted rgb(119,136,85); border-right:0.7500pt dotted rgb(119,136,85); mso-border-right-alt:0.7500pt dotted rgb(119,136,85); border-bottom:0.7500pt dotted rgb(119,136,85); mso-border-bottom-alt:0.7500pt dotted rgb(119,136,85); border-left:0.7500pt dotted rgb(119,136,85); mso-border-left-alt:0.7500pt dotted rgb(119,136,85); padding:10pt 10pt 10pt 10pt ; text-autospace:ideograph-other;"  ><span style="mso-spacerun:'yes'; font-size:9.0000pt; font-family:'Courier New';"  >&lt;p&nbsp;</span><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-size:9.0000pt; font-family:'Courier New';"  >id="red"</span><span style="mso-spacerun:'yes'; font-size:9.0000pt; font-family:'Courier New';"  >&gt;<font face="宋体"  >这个段落是红色。</font><font face="Courier New"  >&lt;/p&gt;</font></span><span style="mso-spacerun:'yes'; font-size:9.0000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:7.5000pt; border-top:0.7500pt dotted rgb(119,136,85); mso-border-top-alt:0.7500pt dotted rgb(119,136,85); border-right:0.7500pt dotted rgb(119,136,85); mso-border-right-alt:0.7500pt dotted rgb(119,136,85); border-bottom:0.7500pt dotted rgb(119,136,85); mso-border-bottom-alt:0.7500pt dotted rgb(119,136,85); border-left:0.7500pt dotted rgb(119,136,85); mso-border-left-alt:0.7500pt dotted rgb(119,136,85); padding:10pt 10pt 10pt 10pt ; text-autospace:ideograph-other;"  ><span style="mso-spacerun:'yes'; font-size:9.0000pt; font-family:'Courier New';"  >&lt;p&nbsp;</span><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-size:9.0000pt; font-family:'Courier New';"  >id="green"</span><span style="mso-spacerun:'yes'; font-size:9.0000pt; font-family:'Courier New';"  >&gt;<font face="宋体"  >这个段落是绿色。</font><font face="Courier New"  >&lt;/p&gt;</font></span><span style="mso-spacerun:'yes'; font-size:9.0000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:9.0000pt; text-autospace:ideograph-other; line-height:13.5000pt;"  ><span style="mso-spacerun:'yes'; color:rgb(221,0,0); font-weight:bold; font-size:10.5000pt; font-family:'Times New Roman';"  >注意：</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  >id&nbsp;<font face="宋体"  >属性只能在每个&nbsp;</font><font face="Times New Roman"  >HTML&nbsp;</font><font face="宋体"  >文档中出现一次</font></span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; text-align:left;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:bold; font-style:normal; font-size:10.5000pt; font-family:'Verdana';"  >CSS&nbsp;<font face="宋体"  >背景属性</font></span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:bold; font-style:normal; font-size:10.5000pt; font-family:'Verdana';"  ></span></p><table style="border-collapse:collapse; mso-table-layout-alt:fixed; padding:0.0000pt 5.4000pt 0.0000pt 5.4000pt ;"  ><tbody><tr><td width="160"  valign="bottom"  style="width:120.3500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(136,136,136); mso-border-left-alt:0.7500pt solid rgb(136,136,136); border-right:0.7500pt solid rgb(136,136,136); mso-border-right-alt:0.7500pt solid rgb(136,136,136); border-top:0.7500pt solid rgb(136,136,136); mso-border-top-alt:0.7500pt solid rgb(136,136,136); border-bottom:0.7500pt solid rgb(136,136,136); mso-border-bottom-alt:0.7500pt solid rgb(136,136,136); background:rgb(204,204,204);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; text-align:left; background:rgb(204,204,204);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:bold; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(204,204,204); mso-shading:rgb(204,204,204);"  >属性</span><span style="color:rgb(0,0,0); font-weight:bold; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(204,204,204); mso-shading:rgb(204,204,204);"  ></span></p></td><td width="324"  valign="bottom"  style="width:243.6000pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(136,136,136); mso-border-right-alt:0.7500pt solid rgb(136,136,136); border-top:0.7500pt solid rgb(136,136,136); mso-border-top-alt:0.7500pt solid rgb(136,136,136); border-bottom:0.7500pt solid rgb(136,136,136); mso-border-bottom-alt:0.7500pt solid rgb(136,136,136); background:rgb(204,204,204);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; text-align:left; background:rgb(204,204,204);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:bold; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(204,204,204); mso-shading:rgb(204,204,204);"  >描述</span><span style="color:rgb(0,0,0); font-weight:bold; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(204,204,204); mso-shading:rgb(204,204,204);"  ></span></p></td></tr><tr><td width="160"  valign="top"  style="width:120.3500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(170,170,170); mso-border-left-alt:0.7500pt solid rgb(170,170,170); border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="color:rgb(0,0,255); font-weight:normal; text-decoration:underline ;font-style:normal; font-size:9.0000pt; font-family:'Arial';"  ><a rel="nofollow" href="http://www.w3school.com.cn/css/pr_background.asp"  >background</a></span></p></td><td width="324"  valign="top"  style="width:243.6000pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >简写属性，作用是将背景属性设置在一个声明中。</span><span style="color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td></tr><tr><td width="160"  valign="top"  style="width:120.3500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(170,170,170); mso-border-left-alt:0.7500pt solid rgb(170,170,170); border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="color:rgb(0,0,255); font-weight:normal; text-decoration:underline ;font-style:normal; font-size:9.0000pt; font-family:'Arial';"  ><a rel="nofollow" href="http://www.w3school.com.cn/css/pr_background-attachment.asp"  >background-attachment</a></span></p></td><td width="324"  valign="top"  style="width:243.6000pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >背景图像是否固定或者随着页面的其余部分滚动。</span><span style="color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td></tr><tr><td width="160"  valign="top"  style="width:120.3500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(170,170,170); mso-border-left-alt:0.7500pt solid rgb(170,170,170); border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="color:rgb(0,0,255); font-weight:normal; text-decoration:underline ;font-style:normal; font-size:9.0000pt; font-family:'Arial';"  ><a rel="nofollow" href="http://www.w3school.com.cn/css/pr_background-color.asp"  >background-color</a></span></p></td><td width="324"  valign="top"  style="width:243.6000pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >设置元素的背景颜色。</span><span style="color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td></tr><tr><td width="160"  valign="top"  style="width:120.3500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(170,170,170); mso-border-left-alt:0.7500pt solid rgb(170,170,170); border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="color:rgb(0,0,255); font-weight:normal; text-decoration:underline ;font-style:normal; font-size:9.0000pt; font-family:'Arial';"  ><a rel="nofollow" href="http://www.w3school.com.cn/css/pr_background-image.asp"  >background-image</a></span></p></td><td width="324"  valign="top"  style="width:243.6000pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >把图像设置为背景。</span><span style="color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td></tr><tr><td width="160"  valign="top"  style="width:120.3500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(170,170,170); mso-border-left-alt:0.7500pt solid rgb(170,170,170); border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="color:rgb(0,0,255); font-weight:normal; text-decoration:underline ;font-style:normal; font-size:9.0000pt; font-family:'Arial';"  ><a rel="nofollow" href="http://www.w3school.com.cn/css/pr_background-position.asp"  >background-position</a></span></p></td><td width="324"  valign="top"  style="width:243.6000pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >设置背景图像的起始位置。</span><span style="color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td></tr><tr><td width="160"  valign="top"  style="width:120.3500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(170,170,170); mso-border-left-alt:0.7500pt solid rgb(170,170,170); border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="color:rgb(0,0,255); font-weight:normal; text-decoration:underline ;font-style:normal; font-size:9.0000pt; font-family:'Arial';"  ><a rel="nofollow" href="http://www.w3school.com.cn/css/pr_background-repeat.asp"  >background-repeat</a></span></p></td><td width="324"  valign="top"  style="width:243.6000pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >设置背景图像是否及如何重复。</span><span style="color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td></tr></table><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; text-align:left;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  >&nbsp;</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:bold; font-style:normal; font-size:10.5000pt; font-family:'Verdana';"  >CSS&nbsp;<font face="宋体"  >文本属性</font></span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:bold; font-style:normal; font-size:10.5000pt; font-family:'Verdana';"  ></span></p><table style="border-collapse:collapse; mso-table-layout-alt:fixed; padding:0.0000pt 5.4000pt 0.0000pt 5.4000pt ;"  ><tbody><tr><td width="113"  valign="bottom"  style="width:85.3500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(136,136,136); mso-border-left-alt:0.7500pt solid rgb(136,136,136); border-right:0.7500pt solid rgb(136,136,136); mso-border-right-alt:0.7500pt solid rgb(136,136,136); border-top:0.7500pt solid rgb(136,136,136); mso-border-top-alt:0.7500pt solid rgb(136,136,136); border-bottom:0.7500pt solid rgb(136,136,136); mso-border-bottom-alt:0.7500pt solid rgb(136,136,136); background:rgb(204,204,204);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; text-align:left; background:rgb(204,204,204);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:bold; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(204,204,204); mso-shading:rgb(204,204,204);"  >属性</span><span style="color:rgb(0,0,0); font-weight:bold; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(204,204,204); mso-shading:rgb(204,204,204);"  ></span></p></td><td width="420"  valign="bottom"  style="width:315.5500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(136,136,136); mso-border-right-alt:0.7500pt solid rgb(136,136,136); border-top:0.7500pt solid rgb(136,136,136); mso-border-top-alt:0.7500pt solid rgb(136,136,136); border-bottom:0.7500pt solid rgb(136,136,136); mso-border-bottom-alt:0.7500pt solid rgb(136,136,136); background:rgb(204,204,204);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; text-align:left; background:rgb(204,204,204);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:bold; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(204,204,204); mso-shading:rgb(204,204,204);"  >描述</span><span style="color:rgb(0,0,0); font-weight:bold; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(204,204,204); mso-shading:rgb(204,204,204);"  ></span></p></td></tr><tr><td width="113"  valign="top"  style="width:85.3500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(170,170,170); mso-border-left-alt:0.7500pt solid rgb(170,170,170); border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="color:rgb(0,0,255); font-weight:normal; text-decoration:underline ;font-style:normal; font-size:9.0000pt; font-family:'Arial';"  ><a rel="nofollow" href="http://www.w3school.com.cn/css/pr_text_color.asp"  >color</a></span></p></td><td width="420"  valign="top"  style="width:315.5500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >设置文本颜色</span><span style="color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td></tr><tr><td width="113"  valign="top"  style="width:85.3500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(170,170,170); mso-border-left-alt:0.7500pt solid rgb(170,170,170); border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="color:rgb(0,0,255); font-weight:normal; text-decoration:underline ;font-style:normal; font-size:9.0000pt; font-family:'Arial';"  ><a rel="nofollow" href="http://www.w3school.com.cn/css/pr_text_direction.asp"  >direction</a></span></p></td><td width="420"  valign="top"  style="width:315.5500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >设置文本方向。</span><span style="color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td></tr><tr><td width="113"  valign="top"  style="width:85.3500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(170,170,170); mso-border-left-alt:0.7500pt solid rgb(170,170,170); border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="color:rgb(0,0,255); font-weight:normal; text-decoration:underline ;font-style:normal; font-size:9.0000pt; font-family:'Arial';"  ><a rel="nofollow" href="http://www.w3school.com.cn/css/pr_dim_line-height.asp"  >line-height</a></span></p></td><td width="420"  valign="top"  style="width:315.5500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >设置行高。</span><span style="color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td></tr><tr><td width="113"  valign="top"  style="width:85.3500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(170,170,170); mso-border-left-alt:0.7500pt solid rgb(170,170,170); border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="color:rgb(0,0,255); font-weight:normal; text-decoration:underline ;font-style:normal; font-size:9.0000pt; font-family:'Arial';"  ><a rel="nofollow" href="http://www.w3school.com.cn/css/pr_text_letter-spacing.asp"  >letter-spacing</a></span></p></td><td width="420"  valign="top"  style="width:315.5500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >设置字符间距。</span><span style="color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td></tr><tr><td width="113"  valign="top"  style="width:85.3500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(170,170,170); mso-border-left-alt:0.7500pt solid rgb(170,170,170); border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="color:rgb(0,0,255); font-weight:normal; text-decoration:underline ;font-style:normal; font-size:9.0000pt; font-family:'Arial';"  ><a rel="nofollow" href="http://www.w3school.com.cn/css/pr_text_text-align.asp"  >text-align</a></span></p></td><td width="420"  valign="top"  style="width:315.5500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >对齐元素中的文本。</span><span style="color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td></tr><tr><td width="113"  valign="top"  style="width:85.3500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(170,170,170); mso-border-left-alt:0.7500pt solid rgb(170,170,170); border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="color:rgb(0,0,255); font-weight:normal; text-decoration:underline ;font-style:normal; font-size:9.0000pt; font-family:'Arial';"  ><a rel="nofollow" href="http://www.w3school.com.cn/css/pr_text_text-decoration.asp"  >text-decoration</a></span></p></td><td width="420"  valign="top"  style="width:315.5500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >向文本添加修饰。</span><span style="color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td></tr><tr><td width="113"  valign="top"  style="width:85.3500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(170,170,170); mso-border-left-alt:0.7500pt solid rgb(170,170,170); border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="color:rgb(0,0,255); font-weight:normal; text-decoration:underline ;font-style:normal; font-size:9.0000pt; font-family:'Arial';"  ><a rel="nofollow" href="http://www.w3school.com.cn/css/pr_text_text-indent.asp"  >text-indent</a></span></p></td><td width="420"  valign="top"  style="width:315.5500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >缩进元素中文本的首行。</span><span style="color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td></tr><tr><td width="113"  valign="top"  style="width:85.3500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(170,170,170); mso-border-left-alt:0.7500pt solid rgb(170,170,170); border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >text-shadow</span><span style="color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td><td width="420"  valign="top"  style="width:315.5500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >设置文本阴影。<font face="Arial"  >CSS2&nbsp;</font><font face="宋体"  >包含该属性，但是&nbsp;</font><font face="Arial"  >CSS2.1&nbsp;</font><font face="宋体"  >没有保留该属性。</font></span><span style="color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td></tr><tr><td width="113"  valign="top"  style="width:85.3500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(170,170,170); mso-border-left-alt:0.7500pt solid rgb(170,170,170); border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="color:rgb(0,0,255); font-weight:normal; text-decoration:underline ;font-style:normal; font-size:9.0000pt; font-family:'Arial';"  ><a rel="nofollow" href="http://www.w3school.com.cn/css/pr_text_text-transform.asp"  >text-transform</a></span></p></td><td width="420"  valign="top"  style="width:315.5500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >控制元素中的字母。</span><span style="color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td></tr><tr><td width="113"  valign="top"  style="width:85.3500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(170,170,170); mso-border-left-alt:0.7500pt solid rgb(170,170,170); border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >unicode-bidi</span><span style="color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td><td width="420"  valign="top"  style="width:315.5500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >设置文本方向。</span><span style="color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td></tr><tr><td width="113"  valign="top"  style="width:85.3500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(170,170,170); mso-border-left-alt:0.7500pt solid rgb(170,170,170); border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="color:rgb(0,0,255); font-weight:normal; text-decoration:underline ;font-style:normal; font-size:9.0000pt; font-family:'Arial';"  ><a rel="nofollow" href="http://www.w3school.com.cn/css/pr_text_white-space.asp"  >white-space</a></span></p></td><td width="420"  valign="top"  style="width:315.5500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >设置元素中空白的处理方式。</span><span style="color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td></tr><tr><td width="113"  valign="top"  style="width:85.3500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(170,170,170); mso-border-left-alt:0.7500pt solid rgb(170,170,170); border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="color:rgb(0,0,255); font-weight:normal; text-decoration:underline ;font-style:normal; font-size:9.0000pt; font-family:'Arial';"  ><a rel="nofollow" href="http://www.w3school.com.cn/css/pr_text_word-spacing.asp"  >word-spacing</a></span></p></td><td width="420"  valign="top"  style="width:315.5500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >设置字间距。</span><span style="color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td></tr></table><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; text-align:left;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  >&nbsp;</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:bold; font-style:normal; font-size:10.5000pt; font-family:'Verdana';"  >CSS&nbsp;<font face="宋体"  >字体属性</font></span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:bold; font-style:normal; font-size:10.5000pt; font-family:'Verdana';"  ></span></p><table style="border-collapse:collapse; mso-table-layout-alt:fixed; padding:0.0000pt 5.4000pt 0.0000pt 5.4000pt ;"  ><tbody><tr><td width="110"  valign="bottom"  style="width:82.8500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(136,136,136); mso-border-left-alt:0.7500pt solid rgb(136,136,136); border-right:0.7500pt solid rgb(136,136,136); mso-border-right-alt:0.7500pt solid rgb(136,136,136); border-top:0.7500pt solid rgb(136,136,136); mso-border-top-alt:0.7500pt solid rgb(136,136,136); border-bottom:0.7500pt solid rgb(136,136,136); mso-border-bottom-alt:0.7500pt solid rgb(136,136,136); background:rgb(204,204,204);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; text-align:left; background:rgb(204,204,204);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:bold; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(204,204,204); mso-shading:rgb(204,204,204);"  >属性</span><span style="color:rgb(0,0,0); font-weight:bold; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(204,204,204); mso-shading:rgb(204,204,204);"  ></span></p></td><td width="466"  valign="bottom"  style="width:349.5000pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(136,136,136); mso-border-right-alt:0.7500pt solid rgb(136,136,136); border-top:0.7500pt solid rgb(136,136,136); mso-border-top-alt:0.7500pt solid rgb(136,136,136); border-bottom:0.7500pt solid rgb(136,136,136); mso-border-bottom-alt:0.7500pt solid rgb(136,136,136); background:rgb(204,204,204);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; text-align:left; background:rgb(204,204,204);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:bold; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(204,204,204); mso-shading:rgb(204,204,204);"  >描述</span><span style="color:rgb(0,0,0); font-weight:bold; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(204,204,204); mso-shading:rgb(204,204,204);"  ></span></p></td></tr><tr><td width="110"  valign="top"  style="width:82.8500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(170,170,170); mso-border-left-alt:0.7500pt solid rgb(170,170,170); border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="color:rgb(0,0,255); font-weight:normal; text-decoration:underline ;font-style:normal; font-size:9.0000pt; font-family:'Arial';"  ><a rel="nofollow" href="http://www.w3school.com.cn/css/pr_font_font.asp"  >font</a></span></p></td><td width="466"  valign="top"  style="width:349.5000pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >简写属性。作用是把所有针对字体的属性设置在一个声明中。</span><span style="color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td></tr><tr><td width="110"  valign="top"  style="width:82.8500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(170,170,170); mso-border-left-alt:0.7500pt solid rgb(170,170,170); border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="color:rgb(0,0,255); font-weight:normal; text-decoration:underline ;font-style:normal; font-size:9.0000pt; font-family:'Arial';"  ><a rel="nofollow" href="http://www.w3school.com.cn/css/pr_font_font-family.asp"  >font-family</a></span></p></td><td width="466"  valign="top"  style="width:349.5000pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >设置字体系列。</span><span style="color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td></tr><tr><td width="110"  valign="top"  style="width:82.8500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(170,170,170); mso-border-left-alt:0.7500pt solid rgb(170,170,170); border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="color:rgb(0,0,255); font-weight:normal; text-decoration:underline ;font-style:normal; font-size:9.0000pt; font-family:'Arial';"  ><a rel="nofollow" href="http://www.w3school.com.cn/css/pr_font_font-size.asp"  >font-size</a></span></p></td><td width="466"  valign="top"  style="width:349.5000pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >设置字体的尺寸。</span><span style="color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td></tr><tr><td width="110"  valign="top"  style="width:82.8500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(170,170,170); mso-border-left-alt:0.7500pt solid rgb(170,170,170); border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="color:rgb(0,0,255); font-weight:normal; text-decoration:underline ;font-style:normal; font-size:9.0000pt; font-family:'Arial';"  ><a rel="nofollow" href="http://www.w3school.com.cn/css/pr_font_font-size-adjust.asp"  >font-size-adjust</a></span></p></td><td width="466"  valign="top"  style="width:349.5000pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >当首选字体不可用时，对替换字体进行智能缩放。（<font face="Arial"  >CSS2.1&nbsp;</font><font face="宋体"  >已删除该属性。）</font></span><span style="color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td></tr><tr><td width="110"  valign="top"  style="width:82.8500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(170,170,170); mso-border-left-alt:0.7500pt solid rgb(170,170,170); border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="color:rgb(0,0,255); font-weight:normal; text-decoration:underline ;font-style:normal; font-size:9.0000pt; font-family:'Arial';"  ><a rel="nofollow" href="http://www.w3school.com.cn/css/pr_font_font-stretch.asp"  >font-stretch</a></span></p></td><td width="466"  valign="top"  style="width:349.5000pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >对字体进行水平拉伸。（<font face="Arial"  >CSS2.1&nbsp;</font><font face="宋体"  >已删除该属性。）</font></span><span style="color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td></tr><tr><td width="110"  valign="top"  style="width:82.8500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(170,170,170); mso-border-left-alt:0.7500pt solid rgb(170,170,170); border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="color:rgb(0,0,255); font-weight:normal; text-decoration:underline ;font-style:normal; font-size:9.0000pt; font-family:'Arial';"  ><a rel="nofollow" href="http://www.w3school.com.cn/css/pr_font_font-style.asp"  >font-style</a></span></p></td><td width="466"  valign="top"  style="width:349.5000pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >设置字体风格。</span><span style="color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td></tr><tr><td width="110"  valign="top"  style="width:82.8500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(170,170,170); mso-border-left-alt:0.7500pt solid rgb(170,170,170); border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="color:rgb(0,0,255); font-weight:normal; text-decoration:underline ;font-style:normal; font-size:9.0000pt; font-family:'Arial';"  ><a rel="nofollow" href="http://www.w3school.com.cn/css/pr_font_font-variant.asp"  >font-variant</a></span></p></td><td width="466"  valign="top"  style="width:349.5000pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >以小型大写字体或者正常字体显示文本。</span><span style="color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td></tr><tr><td width="110"  valign="top"  style="width:82.8500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(170,170,170); mso-border-left-alt:0.7500pt solid rgb(170,170,170); border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="color:rgb(0,0,255); font-weight:normal; text-decoration:underline ;font-style:normal; font-size:9.0000pt; font-family:'Arial';"  ><a rel="nofollow" href="http://www.w3school.com.cn/css/pr_font_weight.asp"  >font-weight</a></span></p></td><td width="466"  valign="top"  style="width:349.5000pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >设置字体的粗细。</span><span style="color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td></tr></table><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; text-align:left;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  >&nbsp;</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:bold; font-style:normal; font-size:10.5000pt; font-family:'Verdana';"  >CSS&nbsp;<font face="宋体"  >列表属性</font><font face="Verdana"  >(list)</font></span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:bold; font-style:normal; font-size:10.5000pt; font-family:'Verdana';"  ></span></p><table style="border-collapse:collapse; mso-table-layout-alt:fixed; padding:0.0000pt 5.4000pt 0.0000pt 5.4000pt ;"  ><tbody><tr><td width="123"  valign="bottom"  style="width:92.3000pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(136,136,136); mso-border-left-alt:0.7500pt solid rgb(136,136,136); border-right:0.7500pt solid rgb(136,136,136); mso-border-right-alt:0.7500pt solid rgb(136,136,136); border-top:0.7500pt solid rgb(136,136,136); mso-border-top-alt:0.7500pt solid rgb(136,136,136); border-bottom:0.7500pt solid rgb(136,136,136); mso-border-bottom-alt:0.7500pt solid rgb(136,136,136); background:rgb(204,204,204);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; text-align:left; background:rgb(204,204,204);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:bold; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(204,204,204); mso-shading:rgb(204,204,204);"  >属性</span><span style="color:rgb(0,0,0); font-weight:bold; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(204,204,204); mso-shading:rgb(204,204,204);"  ></span></p></td><td width="377"  valign="bottom"  style="width:283.2000pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(136,136,136); mso-border-right-alt:0.7500pt solid rgb(136,136,136); border-top:0.7500pt solid rgb(136,136,136); mso-border-top-alt:0.7500pt solid rgb(136,136,136); border-bottom:0.7500pt solid rgb(136,136,136); mso-border-bottom-alt:0.7500pt solid rgb(136,136,136); background:rgb(204,204,204);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; text-align:left; background:rgb(204,204,204);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:bold; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(204,204,204); mso-shading:rgb(204,204,204);"  >描述</span><span style="color:rgb(0,0,0); font-weight:bold; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(204,204,204); mso-shading:rgb(204,204,204);"  ></span></p></td></tr><tr><td width="123"  valign="top"  style="width:92.3000pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(170,170,170); mso-border-left-alt:0.7500pt solid rgb(170,170,170); border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="color:rgb(0,0,255); font-weight:normal; text-decoration:underline ;font-style:normal; font-size:9.0000pt; font-family:'Arial';"  ><a rel="nofollow" href="http://www.w3school.com.cn/css/pr_list-style.asp"  >list-style</a></span></p></td><td width="377"  valign="top"  style="width:283.2000pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >简写属性。用于把所有用于列表的属性设置于一个声明中。</span><span style="color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td></tr><tr><td width="123"  valign="top"  style="width:92.3000pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(170,170,170); mso-border-left-alt:0.7500pt solid rgb(170,170,170); border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="color:rgb(0,0,255); font-weight:normal; text-decoration:underline ;font-style:normal; font-size:9.0000pt; font-family:'Arial';"  ><a rel="nofollow" href="http://www.w3school.com.cn/css/pr_list-style-image.asp"  >list-style-image</a></span></p></td><td width="377"  valign="top"  style="width:283.2000pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >将图象设置为列表项标志。</span><span style="color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td></tr><tr><td width="123"  valign="top"  style="width:92.3000pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(170,170,170); mso-border-left-alt:0.7500pt solid rgb(170,170,170); border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="color:rgb(0,0,255); font-weight:normal; text-decoration:underline ;font-style:normal; font-size:9.0000pt; font-family:'Arial';"  ><a rel="nofollow" href="http://www.w3school.com.cn/css/pr_list-style-position.asp"  >list-style-position</a></span></p></td><td width="377"  valign="top"  style="width:283.2000pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >设置列表中列表项标志的位置。</span><span style="color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td></tr><tr><td width="123"  valign="top"  style="width:92.3000pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(170,170,170); mso-border-left-alt:0.7500pt solid rgb(170,170,170); border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="color:rgb(0,0,255); font-weight:normal; text-decoration:underline ;font-style:normal; font-size:9.0000pt; font-family:'Arial';"  ><a rel="nofollow" href="http://www.w3school.com.cn/css/pr_list-style-type.asp"  >list-style-type</a></span></p></td><td width="377"  valign="top"  style="width:283.2000pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >设置列表项标志的类型。</span><span style="color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td></tr><tr><td width="123"  valign="top"  style="width:92.3000pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(170,170,170); mso-border-left-alt:0.7500pt solid rgb(170,170,170); border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >marker-offset</span><span style="color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td><td width="377"  valign="top"  style="width:283.2000pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >&nbsp;</span><span style="color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td></tr></table><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; text-align:left;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  >&nbsp;</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:bold; font-style:normal; font-size:10.5000pt; font-family:'Verdana';"  >CSS&nbsp;Table&nbsp;<font face="宋体"  >属性</font></span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:bold; font-style:normal; font-size:10.5000pt; font-family:'Verdana';"  ></span></p><table style="border-collapse:collapse; mso-table-layout-alt:fixed; padding:0.0000pt 5.4000pt 0.0000pt 5.4000pt ;"  ><tbody><tr><td width="117"  valign="bottom"  style="width:87.8500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(136,136,136); mso-border-left-alt:0.7500pt solid rgb(136,136,136); border-right:0.7500pt solid rgb(136,136,136); mso-border-right-alt:0.7500pt solid rgb(136,136,136); border-top:0.7500pt solid rgb(136,136,136); mso-border-top-alt:0.7500pt solid rgb(136,136,136); border-bottom:0.7500pt solid rgb(136,136,136); mso-border-bottom-alt:0.7500pt solid rgb(136,136,136); background:rgb(204,204,204);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; text-align:left; background:rgb(204,204,204);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:bold; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(204,204,204); mso-shading:rgb(204,204,204);"  >属性</span><span style="color:rgb(0,0,0); font-weight:bold; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(204,204,204); mso-shading:rgb(204,204,204);"  ></span></p></td><td width="272"  valign="bottom"  style="width:204.0000pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(136,136,136); mso-border-right-alt:0.7500pt solid rgb(136,136,136); border-top:0.7500pt solid rgb(136,136,136); mso-border-top-alt:0.7500pt solid rgb(136,136,136); border-bottom:0.7500pt solid rgb(136,136,136); mso-border-bottom-alt:0.7500pt solid rgb(136,136,136); background:rgb(204,204,204);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; text-align:left; background:rgb(204,204,204);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:bold; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(204,204,204); mso-shading:rgb(204,204,204);"  >描述</span><span style="color:rgb(0,0,0); font-weight:bold; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(204,204,204); mso-shading:rgb(204,204,204);"  ></span></p></td></tr><tr><td width="117"  valign="top"  style="width:87.8500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(170,170,170); mso-border-left-alt:0.7500pt solid rgb(170,170,170); border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="color:rgb(0,0,255); font-weight:normal; text-decoration:underline ;font-style:normal; font-size:9.0000pt; font-family:'Arial';"  ><a rel="nofollow" href="http://www.w3school.com.cn/css/pr_tab_border-collapse.asp"  >border-collapse</a></span></p></td><td width="272"  valign="top"  style="width:204.0000pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >设置是否把表格边框合并为单一的边框。</span><span style="color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td></tr><tr><td width="117"  valign="top"  style="width:87.8500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(170,170,170); mso-border-left-alt:0.7500pt solid rgb(170,170,170); border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="color:rgb(0,0,255); font-weight:normal; text-decoration:underline ;font-style:normal; font-size:9.0000pt; font-family:'Arial';"  ><a rel="nofollow" href="http://www.w3school.com.cn/css/pr_tab_border-spacing.asp"  >border-spacing</a></span></p></td><td width="272"  valign="top"  style="width:204.0000pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >设置分隔单元格边框的距离。</span><span style="color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td></tr><tr><td width="117"  valign="top"  style="width:87.8500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(170,170,170); mso-border-left-alt:0.7500pt solid rgb(170,170,170); border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="color:rgb(0,0,255); font-weight:normal; text-decoration:underline ;font-style:normal; font-size:9.0000pt; font-family:'Arial';"  ><a rel="nofollow" href="http://www.w3school.com.cn/css/pr_tab_caption-side.asp"  >caption-side</a></span></p></td><td width="272"  valign="top"  style="width:204.0000pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >设置表格标题的位置。</span><span style="color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td></tr><tr><td width="117"  valign="top"  style="width:87.8500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(170,170,170); mso-border-left-alt:0.7500pt solid rgb(170,170,170); border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="color:rgb(0,0,255); font-weight:normal; text-decoration:underline ;font-style:normal; font-size:9.0000pt; font-family:'Arial';"  ><a rel="nofollow" href="http://www.w3school.com.cn/css/pr_tab_empty-cells.asp"  >empty-cells</a></span></p></td><td width="272"  valign="top"  style="width:204.0000pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >设置是否显示表格中的空单元格。</span><span style="color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td></tr><tr><td width="117"  valign="top"  style="width:87.8500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(170,170,170); mso-border-left-alt:0.7500pt solid rgb(170,170,170); border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="color:rgb(0,0,255); font-weight:normal; text-decoration:underline ;font-style:normal; font-size:9.0000pt; font-family:'Arial';"  ><a rel="nofollow" href="http://www.w3school.com.cn/css/pr_tab_table-layout.asp"  >table-layout</a></span></p></td><td width="272"  valign="top"  style="width:204.0000pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >设置显示单元、行和列的算法。</span><span style="color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:9.0000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td></tr></table><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; text-align:left;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  >&nbsp;</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:bold; font-style:normal; font-size:10.5000pt; font-family:'Verdana';"  >CSS&nbsp;<font face="宋体"  >边框属性</font></span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:bold; font-style:normal; font-size:10.5000pt; font-family:'Verdana';"  ></span></p><p style="margin-bottom:0pt; margin-top:9.0000pt; text-autospace:ideograph-other; line-height:13.5000pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  >"CSS"&nbsp;<font face="宋体"  >列中的数字指示哪个&nbsp;</font><font face="Times New Roman"  >CSS&nbsp;</font><font face="宋体"  >版本定义了该属性。</font></span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  ></span></p><table style="border-collapse:collapse; mso-table-layout-alt:fixed; padding:0.0000pt 5.4000pt 0.0000pt 5.4000pt ;"  ><tbody><tr><td width="156"  valign="bottom"  style="width:117.0000pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(136,136,136); mso-border-left-alt:0.7500pt solid rgb(136,136,136); border-right:0.7500pt solid rgb(136,136,136); mso-border-right-alt:0.7500pt solid rgb(136,136,136); border-top:0.7500pt solid rgb(136,136,136); mso-border-top-alt:0.7500pt solid rgb(136,136,136); border-bottom:0.7500pt solid rgb(136,136,136); mso-border-bottom-alt:0.7500pt solid rgb(136,136,136); background:rgb(204,204,204);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; text-align:left; background:rgb(204,204,204);"  ><span style="mso-spacerun:'yes'; font-weight:bold; font-size:10.5000pt; font-family:'Arial'; background:rgb(204,204,204); mso-shading:rgb(204,204,204);"  >属性</span><span style="font-weight:bold; font-size:10.5000pt; font-family:'Arial'; background:rgb(204,204,204); mso-shading:rgb(204,204,204);"  ></span></p></td><td width="363"  valign="bottom"  style="width:272.2500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(136,136,136); mso-border-right-alt:0.7500pt solid rgb(136,136,136); border-top:0.7500pt solid rgb(136,136,136); mso-border-top-alt:0.7500pt solid rgb(136,136,136); border-bottom:0.7500pt solid rgb(136,136,136); mso-border-bottom-alt:0.7500pt solid rgb(136,136,136); background:rgb(204,204,204);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; text-align:left; background:rgb(204,204,204);"  ><span style="mso-spacerun:'yes'; font-weight:bold; font-size:10.5000pt; font-family:'Arial'; background:rgb(204,204,204); mso-shading:rgb(204,204,204);"  >描述</span><span style="font-weight:bold; font-size:10.5000pt; font-family:'Arial'; background:rgb(204,204,204); mso-shading:rgb(204,204,204);"  ></span></p></td><td width="42"  valign="bottom"  style="width:31.6500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(136,136,136); mso-border-right-alt:0.7500pt solid rgb(136,136,136); border-top:0.7500pt solid rgb(136,136,136); mso-border-top-alt:0.7500pt solid rgb(136,136,136); border-bottom:0.7500pt solid rgb(136,136,136); mso-border-bottom-alt:0.7500pt solid rgb(136,136,136); background:rgb(204,204,204);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; text-align:left; background:rgb(204,204,204);"  ><span style="mso-spacerun:'yes'; font-weight:bold; font-size:10.5000pt; font-family:'Arial'; background:rgb(204,204,204); mso-shading:rgb(204,204,204);"  >CSS</span><span style="font-weight:bold; font-size:10.5000pt; font-family:'Arial'; background:rgb(204,204,204); mso-shading:rgb(204,204,204);"  ></span></p></td></tr><tr><td width="156"  valign="top"  style="width:117.0000pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(170,170,170); mso-border-left-alt:0.7500pt solid rgb(170,170,170); border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="color:rgb(144,11,9); text-decoration:underline ;font-size:10.5000pt; font-family:'Arial';"  ><a rel="nofollow" href="http://www.w3school.com.cn/css/pr_outline.asp"  >outline</a></span></p></td><td width="363"  valign="top"  style="width:272.2500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >在一个声明中设置所有的轮廓属性。</span><span style="font-size:10.5000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td><td width="42"  valign="top"  style="width:31.6500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="font-size:10.5000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >2</span><span style="font-size:10.5000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td></tr><tr><td width="156"  valign="top"  style="width:117.0000pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(170,170,170); mso-border-left-alt:0.7500pt solid rgb(170,170,170); border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="color:rgb(144,11,9); text-decoration:underline ;font-size:10.5000pt; font-family:'Arial';"  ><a rel="nofollow" href="http://www.w3school.com.cn/css/pr_outline-color.asp"  >outline-color</a></span></p></td><td width="363"  valign="top"  style="width:272.2500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >设置轮廓的颜色。</span><span style="font-size:10.5000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td><td width="42"  valign="top"  style="width:31.6500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="font-size:10.5000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >2</span><span style="font-size:10.5000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td></tr><tr><td width="156"  valign="top"  style="width:117.0000pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(170,170,170); mso-border-left-alt:0.7500pt solid rgb(170,170,170); border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="color:rgb(144,11,9); text-decoration:underline ;font-size:10.5000pt; font-family:'Arial';"  ><a rel="nofollow" href="http://www.w3school.com.cn/css/pr_outline-style.asp"  >outline-style</a></span></p></td><td width="363"  valign="top"  style="width:272.2500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >设置轮廓的样式。</span><span style="font-size:10.5000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td><td width="42"  valign="top"  style="width:31.6500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="font-size:10.5000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >2</span><span style="font-size:10.5000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td></tr><tr><td width="156"  valign="top"  style="width:117.0000pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:0.7500pt solid rgb(170,170,170); mso-border-left-alt:0.7500pt solid rgb(170,170,170); border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="color:rgb(144,11,9); text-decoration:underline ;font-size:10.5000pt; font-family:'Arial';"  ><a rel="nofollow" href="http://www.w3school.com.cn/css/pr_outline-width.asp"  >outline-width</a></span></p></td><td width="363"  valign="top"  style="width:272.2500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >设置轮廓的宽度。</span><span style="font-size:10.5000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td><td width="42"  valign="top"  style="width:31.6500pt; padding:3.7500pt 11.2500pt 3.7500pt 3.7500pt ; border-left:none; mso-border-left-alt:none; border-right:0.7500pt solid rgb(170,170,170); mso-border-right-alt:0.7500pt solid rgb(170,170,170); border-top:none; mso-border-top-alt:0.7500pt solid rgb(170,170,170); border-bottom:0.7500pt solid rgb(170,170,170); mso-border-bottom-alt:0.7500pt solid rgb(170,170,170); background:rgb(239,239,239);"  ><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other; background:rgb(239,239,239);"  ><span style="font-size:10.5000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  >2</span><span style="font-size:10.5000pt; font-family:'Arial'; background:rgb(239,239,239); mso-shading:rgb(239,239,239);"  ></span></p></td></tr></table><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p></div></div>&nbsp;</div></div>]]></description>
	    <author><![CDATA[long1]]></author>
	    <comments>http://blog.163.com/lfw2565295@126/blog/static/1220051620123234439612</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/lfw2565295@126/blog/static/1220051620123234439612</guid>
    <pubDate>Mon, 2 Apr 2012 16:13:11 +0800</pubDate>
    <dcterms:modified>2012-04-02T19:55:09+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[开发部署一个简单的Servlet]]></title>	
    <link>http://blog.163.com/lfw2565295@126/blog/static/1220051620123110337594</link>
    <description><![CDATA[<div><p style="margin-bottom:0pt; margin-top:0pt; text-align:center;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-size:24.0000pt; font-family:'黑体';"  >开发部署一个简单的</span><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-size:24.0000pt; font-family:'黑体';"  >S</span><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-size:24.0000pt; font-family:'黑体';"  >ervlet</span><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-size:24.0000pt; font-family:'黑体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >Servlet<font face="宋体"  >程序必须通过</font><font face="Times New Roman"  >servlet</font><font face="宋体"  >引擎来启动运行，并且存储目录有特殊要求，通常需要存储在</font><font face="Times New Roman"  >&lt;WEB&nbsp;</font><font face="宋体"  >应用程序目录</font><font face="Times New Roman"  >&gt;\WEB-INF\classed\</font><font face="宋体"  >目录中。</font><font face="Times New Roman"  >Servlet</font><font face="宋体"  >程序必须在</font><font face="Times New Roman"  >web</font><font face="宋体"  >应用程序的</font><font face="Times New Roman"  >web.xml</font><font face="宋体"  >文件中经行注册和映射其访问路径，才可以被</font><font face="Times New Roman"  >servlet</font><font face="宋体"  >引擎加载和被外界访问。</font></span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >MyEclispe<font face="宋体"  >中，新建一个</font><font face="Times New Roman"  >servlet</font><font face="宋体"  >，在新建，</font><font face="Times New Roman"  >others</font><font face="宋体"  >中的</font><font face="Times New Roman"  >MyEclipse</font><font face="宋体"  >中的</font><font face="Times New Roman"  >web</font><font face="宋体"  >中的</font><font face="Times New Roman"  >Servlet</font><font face="宋体"  >中选中</font><font face="Times New Roman"  >(servlet&nbsp;wizard</font><font face="宋体"  >意思：</font></span><span style="mso-spacerun:'yes'; color:rgb(99,140,11); font-weight:normal; font-style:normal; font-size:10.5000pt; font-family:'Arial';"  >向导程序</span><span style="mso-spacerun:'yes'; color:rgb(67,67,67); font-weight:normal; font-style:normal; font-size:10.5000pt; font-family:'Arial';"  >(</span><span style="mso-spacerun:'yes'; color:rgb(99,140,11); font-weight:normal; font-style:normal; font-size:10.5000pt; font-family:'Arial';"  >Wizard</span><span style="mso-spacerun:'yes'; color:rgb(67,67,67); font-weight:normal; font-style:normal; font-size:10.5000pt; font-family:'Arial';"  >)</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  >&nbsp;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >)<font face="宋体"  >，</font><font face="Times New Roman"  >package</font><font face="宋体"  >可以写成</font><font face="Times New Roman"  >com,</font><font face="宋体"  >名字自己定。下一步，就会自动生成</font><font face="Times New Roman"  >Generate/Map&nbsp;web.xml&nbsp;file</font><font face="宋体"  >了，包括</font><font face="Times New Roman"  >servlet/jsp&nbsp;name</font><font face="宋体"  >，</font><font face="Times New Roman"  >mapping&nbsp;url,&nbsp;file&nbsp;path&nbsp;of&nbsp;web.xml</font><font face="宋体"  >，</font><font face="Times New Roman"  >display&nbsp;name</font><font face="宋体"  >和</font><font face="Times New Roman"  >description.</font></span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><br></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >自动产生的<font face="Times New Roman"  >TestServlet.java:</font></span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(127,0,85); font-weight:bold; font-size:10.5000pt; font-family:'Courier New';"  >package</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;com;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(127,0,85); font-weight:bold; font-size:10.5000pt; font-family:'Courier New';"  >import</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;java.io.IOException;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(127,0,85); font-weight:bold; font-size:10.5000pt; font-family:'Courier New';"  >import</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;java.io.PrintWriter;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(127,0,85); font-weight:bold; font-size:10.5000pt; font-family:'Courier New';"  >import</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;javax.servlet.ServletException;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(127,0,85); font-weight:bold; font-size:10.5000pt; font-family:'Courier New';"  >import</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;javax.servlet.http.HttpServlet;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(127,0,85); font-weight:bold; font-size:10.5000pt; font-family:'Courier New';"  >import</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;javax.servlet.http.HttpServletRequest;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(127,0,85); font-weight:bold; font-size:10.5000pt; font-family:'Courier New';"  >import</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;javax.servlet.http.HttpServletResponse;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(127,0,85); font-weight:bold; font-size:10.5000pt; font-family:'Courier New';"  >public</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;</span><span style="mso-spacerun:'yes'; color:rgb(127,0,85); font-weight:bold; font-size:10.5000pt; font-family:'Courier New';"  >class</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); text-decoration:underline ;font-size:10.5000pt; font-family:'Courier New';"  >TestServlet</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;</span><span style="mso-spacerun:'yes'; color:rgb(127,0,85); font-weight:bold; font-size:10.5000pt; font-family:'Courier New';"  >extends</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;HttpServlet&nbsp;{</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  >/**</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;*&nbsp;Constructor&nbsp;of&nbsp;the&nbsp;object.</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;*/</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(127,0,85); font-weight:bold; font-size:10.5000pt; font-family:'Courier New';"  >public</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;TestServlet()&nbsp;{</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(127,0,85); font-weight:bold; font-size:10.5000pt; font-family:'Courier New';"  >super</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >();</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >}</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  >/**</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;*&nbsp;Destruction&nbsp;of&nbsp;the&nbsp;</span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); text-decoration:underline ;font-size:10.5000pt; font-family:'Courier New';"  >servlet</span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  >.&nbsp;</span><span style="mso-spacerun:'yes'; color:rgb(127,127,159); font-size:10.5000pt; font-family:'Courier New';"  >&lt;br&gt;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;*/</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(127,0,85); font-weight:bold; font-size:10.5000pt; font-family:'Courier New';"  >public</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;</span><span style="mso-spacerun:'yes'; color:rgb(127,0,85); font-weight:bold; font-size:10.5000pt; font-family:'Courier New';"  >void</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;destroy()&nbsp;{</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(127,0,85); font-weight:bold; font-size:10.5000pt; font-family:'Courier New';"  >super</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >.destroy();&nbsp;</span><span style="mso-spacerun:'yes'; color:rgb(63,127,95); font-size:10.5000pt; font-family:'Courier New';"  >//&nbsp;Just&nbsp;puts&nbsp;"destroy"&nbsp;string&nbsp;in&nbsp;log</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(63,127,95); font-size:10.5000pt; font-family:'Courier New';"  >//&nbsp;Put&nbsp;your&nbsp;code&nbsp;here</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >}</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  >/**</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;*&nbsp;The&nbsp;doGet&nbsp;method&nbsp;of&nbsp;the&nbsp;</span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); text-decoration:underline ;font-size:10.5000pt; font-family:'Courier New';"  >servlet</span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  >.&nbsp;</span><span style="mso-spacerun:'yes'; color:rgb(127,127,159); font-size:10.5000pt; font-family:'Courier New';"  >&lt;br&gt;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;*</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;*&nbsp;This&nbsp;method&nbsp;is&nbsp;called&nbsp;when&nbsp;a&nbsp;form&nbsp;has&nbsp;its&nbsp;tag&nbsp;value&nbsp;method&nbsp;equals&nbsp;to&nbsp;get.</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;*&nbsp;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;*&nbsp;</span><span style="mso-spacerun:'yes'; color:rgb(127,159,191); font-weight:bold; font-size:10.5000pt; font-family:'Courier New';"  >@param</span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;request&nbsp;the&nbsp;request&nbsp;send&nbsp;by&nbsp;the&nbsp;client&nbsp;to&nbsp;the&nbsp;server</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;*&nbsp;</span><span style="mso-spacerun:'yes'; color:rgb(127,159,191); font-weight:bold; font-size:10.5000pt; font-family:'Courier New';"  >@param</span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;response&nbsp;the&nbsp;response&nbsp;send&nbsp;by&nbsp;the&nbsp;server&nbsp;to&nbsp;the&nbsp;client</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;*&nbsp;</span><span style="mso-spacerun:'yes'; color:rgb(127,159,191); font-weight:bold; font-size:10.5000pt; font-family:'Courier New';"  >@throws</span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;ServletException&nbsp;if&nbsp;an&nbsp;error&nbsp;occurred</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;*&nbsp;</span><span style="mso-spacerun:'yes'; color:rgb(127,159,191); font-weight:bold; font-size:10.5000pt; font-family:'Courier New';"  >@throws</span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;IOException&nbsp;if&nbsp;an&nbsp;error&nbsp;occurred</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;*/</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(127,0,85); font-weight:bold; font-size:10.5000pt; font-family:'Courier New';"  >public</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;</span><span style="mso-spacerun:'yes'; color:rgb(127,0,85); font-weight:bold; font-size:10.5000pt; font-family:'Courier New';"  >void</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;doGet(HttpServletRequest&nbsp;request,&nbsp;HttpServletResponse&nbsp;response)</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(127,0,85); font-weight:bold; font-size:10.5000pt; font-family:'Courier New';"  >throws</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;ServletException,&nbsp;IOException&nbsp;{</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >response.setContentType(</span><span style="mso-spacerun:'yes'; color:rgb(42,0,255); font-size:10.5000pt; font-family:'Courier New';"  >"text/html"</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >);</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >PrintWriter&nbsp;out&nbsp;=&nbsp;response.getWriter();</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >out</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >.println(</span><span style="mso-spacerun:'yes'; color:rgb(42,0,255); font-size:10.5000pt; font-family:'Courier New';"  >"&lt;!DOCTYPE&nbsp;HTML&nbsp;PUBLIC&nbsp;\"-//W3C//DTD&nbsp;HTML&nbsp;4.01&nbsp;Transitional//EN\"&gt;"</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >);</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >out.println(</span><span style="mso-spacerun:'yes'; color:rgb(42,0,255); font-size:10.5000pt; font-family:'Courier New';"  >"&lt;HTML&gt;"</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >);</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >out.println(</span><span style="mso-spacerun:'yes'; color:rgb(42,0,255); font-size:10.5000pt; font-family:'Courier New';"  >"&nbsp;&nbsp;&lt;HEAD&gt;&lt;TITLE&gt;A&nbsp;Servlet&lt;/TITLE&gt;&lt;/HEAD&gt;"</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >);</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >out.println(</span><span style="mso-spacerun:'yes'; color:rgb(42,0,255); font-size:10.5000pt; font-family:'Courier New';"  >"&nbsp;&nbsp;&lt;BODY&gt;"</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >);</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >out.print(</span><span style="mso-spacerun:'yes'; color:rgb(42,0,255); font-size:10.5000pt; font-family:'Courier New';"  >"&nbsp;&nbsp;&nbsp;&nbsp;This&nbsp;is&nbsp;"</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >);</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >out.print(</span><span style="mso-spacerun:'yes'; color:rgb(127,0,85); font-weight:bold; font-size:10.5000pt; font-family:'Courier New';"  >this</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >.getClass());</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >out.println(</span><span style="mso-spacerun:'yes'; color:rgb(42,0,255); font-size:10.5000pt; font-family:'Courier New';"  >",&nbsp;using&nbsp;the&nbsp;GET&nbsp;method"</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >);</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >out.println(</span><span style="mso-spacerun:'yes'; color:rgb(42,0,255); font-size:10.5000pt; font-family:'Courier New';"  >"&nbsp;&nbsp;&lt;/BODY&gt;"</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >);</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >out.println(</span><span style="mso-spacerun:'yes'; color:rgb(42,0,255); font-size:10.5000pt; font-family:'Courier New';"  >"&lt;/HTML&gt;"</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >);</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >out.flush();</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >out.close();</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >}</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  >/**</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;*&nbsp;The&nbsp;doPost&nbsp;method&nbsp;of&nbsp;the&nbsp;</span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); text-decoration:underline ;font-size:10.5000pt; font-family:'Courier New';"  >servlet</span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  >.&nbsp;</span><span style="mso-spacerun:'yes'; color:rgb(127,127,159); font-size:10.5000pt; font-family:'Courier New';"  >&lt;br&gt;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;*</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;*&nbsp;This&nbsp;method&nbsp;is&nbsp;called&nbsp;when&nbsp;a&nbsp;form&nbsp;has&nbsp;its&nbsp;tag&nbsp;value&nbsp;method&nbsp;equals&nbsp;to&nbsp;post.</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;*&nbsp;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;*&nbsp;</span><span style="mso-spacerun:'yes'; color:rgb(127,159,191); font-weight:bold; font-size:10.5000pt; font-family:'Courier New';"  >@param</span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;request&nbsp;the&nbsp;request&nbsp;send&nbsp;by&nbsp;the&nbsp;client&nbsp;to&nbsp;the&nbsp;server</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;*&nbsp;</span><span style="mso-spacerun:'yes'; color:rgb(127,159,191); font-weight:bold; font-size:10.5000pt; font-family:'Courier New';"  >@param</span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;response&nbsp;the&nbsp;response&nbsp;send&nbsp;by&nbsp;the&nbsp;server&nbsp;to&nbsp;the&nbsp;client</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;*&nbsp;</span><span style="mso-spacerun:'yes'; color:rgb(127,159,191); font-weight:bold; font-size:10.5000pt; font-family:'Courier New';"  >@throws</span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;ServletException&nbsp;if&nbsp;an&nbsp;error&nbsp;occurred</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;*&nbsp;</span><span style="mso-spacerun:'yes'; color:rgb(127,159,191); font-weight:bold; font-size:10.5000pt; font-family:'Courier New';"  >@throws</span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;IOException&nbsp;if&nbsp;an&nbsp;error&nbsp;occurred</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;*/</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(127,0,85); font-weight:bold; font-size:10.5000pt; font-family:'Courier New';"  >public</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;</span><span style="mso-spacerun:'yes'; color:rgb(127,0,85); font-weight:bold; font-size:10.5000pt; font-family:'Courier New';"  >void</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;doPost(HttpServletRequest&nbsp;request,&nbsp;HttpServletResponse&nbsp;response)</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(127,0,85); font-weight:bold; font-size:10.5000pt; font-family:'Courier New';"  >throws</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;ServletException,&nbsp;IOException&nbsp;{</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >response.setContentType(</span><span style="mso-spacerun:'yes'; color:rgb(42,0,255); font-size:10.5000pt; font-family:'Courier New';"  >"text/html"</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >);</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >PrintWriter&nbsp;out&nbsp;=&nbsp;response.getWriter();</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >out</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >.println(</span><span style="mso-spacerun:'yes'; color:rgb(42,0,255); font-size:10.5000pt; font-family:'Courier New';"  >"&lt;!DOCTYPE&nbsp;HTML&nbsp;PUBLIC&nbsp;\"-//W3C//DTD&nbsp;HTML&nbsp;4.01&nbsp;Transitional//EN\"&gt;"</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >);</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >out.println(</span><span style="mso-spacerun:'yes'; color:rgb(42,0,255); font-size:10.5000pt; font-family:'Courier New';"  >"&lt;HTML&gt;"</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >);</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >out.println(</span><span style="mso-spacerun:'yes'; color:rgb(42,0,255); font-size:10.5000pt; font-family:'Courier New';"  >"&nbsp;&nbsp;&lt;HEAD&gt;&lt;TITLE&gt;A&nbsp;Servlet&lt;/TITLE&gt;&lt;/HEAD&gt;"</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >);</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >out.println(</span><span style="mso-spacerun:'yes'; color:rgb(42,0,255); font-size:10.5000pt; font-family:'Courier New';"  >"&nbsp;&nbsp;&lt;BODY&gt;"</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >);</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >out.print(</span><span style="mso-spacerun:'yes'; color:rgb(42,0,255); font-size:10.5000pt; font-family:'Courier New';"  >"&nbsp;&nbsp;&nbsp;&nbsp;This&nbsp;is&nbsp;"</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >);</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >out.print(</span><span style="mso-spacerun:'yes'; color:rgb(127,0,85); font-weight:bold; font-size:10.5000pt; font-family:'Courier New';"  >this</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >.getClass());</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >out.println(</span><span style="mso-spacerun:'yes'; color:rgb(42,0,255); font-size:10.5000pt; font-family:'Courier New';"  >",&nbsp;using&nbsp;the&nbsp;POST&nbsp;method"</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >);</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >out.println(</span><span style="mso-spacerun:'yes'; color:rgb(42,0,255); font-size:10.5000pt; font-family:'Courier New';"  >"&nbsp;&nbsp;&lt;/BODY&gt;"</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >);</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >out.println(</span><span style="mso-spacerun:'yes'; color:rgb(42,0,255); font-size:10.5000pt; font-family:'Courier New';"  >"&lt;/HTML&gt;"</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >);</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >out.flush();</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >out.close();</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >}</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  >/**</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;*&nbsp;Initialization&nbsp;of&nbsp;the&nbsp;</span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); text-decoration:underline ;font-size:10.5000pt; font-family:'Courier New';"  >servlet</span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  >.&nbsp;</span><span style="mso-spacerun:'yes'; color:rgb(127,127,159); font-size:10.5000pt; font-family:'Courier New';"  >&lt;br&gt;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;*</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;*&nbsp;</span><span style="mso-spacerun:'yes'; color:rgb(127,159,191); font-weight:bold; font-size:10.5000pt; font-family:'Courier New';"  >@throws</span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;ServletException&nbsp;if&nbsp;an&nbsp;error&nbsp;occurs</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(63,95,191); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;*/</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(127,0,85); font-weight:bold; font-size:10.5000pt; font-family:'Courier New';"  >public</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;</span><span style="mso-spacerun:'yes'; color:rgb(127,0,85); font-weight:bold; font-size:10.5000pt; font-family:'Courier New';"  >void</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;init()&nbsp;</span><span style="mso-spacerun:'yes'; color:rgb(127,0,85); font-weight:bold; font-size:10.5000pt; font-family:'Courier New';"  >throws</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >&nbsp;ServletException&nbsp;{</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(63,127,95); font-size:10.5000pt; font-family:'Courier New';"  >//&nbsp;Put&nbsp;your&nbsp;code&nbsp;here</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  > </span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >}</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >}</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-size:14.0000pt; font-family:'黑体';"  >自动产生的web.xml:</span><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-size:14.0000pt; font-family:'黑体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&lt;?xml&nbsp;version="1.0"&nbsp;encoding="UTF-8"?&gt;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&lt;web-app&nbsp;version="2.4"&nbsp;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  > </span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >xmlns="http://java.sun.com/xml/ns/j2ee"&nbsp;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  > </span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&nbsp;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  > </span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee&nbsp;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  > </span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"&gt;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&nbsp;&lt;servlet&gt;</span><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&nbsp;&nbsp;&nbsp;&lt;description&gt;This&nbsp;is&nbsp;the&nbsp;description&nbsp;of&nbsp;my&nbsp;J2EE&nbsp;component&lt;/description&gt;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&nbsp;&nbsp;&nbsp;&lt;display-name&gt;This&nbsp;is&nbsp;the&nbsp;display&nbsp;name&nbsp;of&nbsp;my&nbsp;J2EE&nbsp;component&lt;/display-name&gt;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&nbsp;&nbsp;&nbsp;&lt;servlet-name&gt;TestServlet&lt;/servlet-name&gt;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&nbsp;&nbsp;&nbsp;&lt;servlet-class&gt;com.TestServlet&lt;/servlet-class&gt;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&nbsp;&lt;/servlet&gt;</span><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&nbsp;&lt;servlet-mapping&gt;</span><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&nbsp;&nbsp;&nbsp;&lt;servlet-name&gt;TestServlet&lt;/servlet-name&gt;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&nbsp;&nbsp;&nbsp;&lt;url-pattern&gt;/servlet/TestServlet&lt;/url-pattern&gt;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&nbsp;&lt;/servlet-mapping&gt;</span><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&nbsp;&lt;welcome-file-list&gt;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&nbsp;&nbsp;&nbsp;&lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&nbsp;&lt;/welcome-file-list&gt;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&lt;/web-app&gt;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >我<font face="Times New Roman"  >tomcat</font><font face="宋体"  >的虚拟路径需要添加</font><font face="Times New Roman"  >\web</font><font face="宋体"  >，则浏览器中输入：</font></span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span><a rel="nofollow" href="http://10.7.16.4/web/servlet/TestServlet"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,255); text-decoration:underline ;font-size:10.5000pt; font-family:'Times New Roman';"  >http://10.7.16.4/web/servlet/TestServlet</span></a></span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  >&nbsp;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >后者的</span><span style="mso-spacerun:'yes'; color:rgb(0,0,255); text-decoration:underline ;font-size:10.5000pt; font-family:'Times New Roman';"  >/servlet/TestServlet</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >是</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >&lt;url-pattern&gt;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >映射路径，用来访问</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >servlet</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-weight:bold; font-size:10.5000pt; font-family:'宋体';"  >显示</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >:</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-weight:normal; font-style:normal; font-size:13.5000pt; font-family:'宋体';"  >This&nbsp;is&nbsp;class&nbsp;com.TestServlet,&nbsp;using&nbsp;the&nbsp;GET&nbsp;method</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  >&nbsp;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-size:10.5000pt; font-family:'宋体';"  >是调用了<font face="Times New Roman"  >doGet</font><font face="宋体"  >函数</font></span><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >下面的例子展示应用实例，采用<font face="Times New Roman"  >JSP+JavaBean+Servlet</font><font face="宋体"  >实现留言板</font></span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-size:10.5000pt; font-family:'宋体';"  >新建一个<font face="Times New Roman"  >sql</font><font face="宋体"  >数据库</font></span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >：</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-numeric; text-autospace:ideograph-other; text-align:justify;"  ><span style="mso-spacerun:'yes'; font-size:14.0000pt; font-family:'宋体';"  >create&nbsp;database&nbsp;liuyan;</span><span style="mso-spacerun:'yes'; font-size:14.0000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-numeric; text-autospace:ideograph-other; text-align:justify;"  ><span style="mso-spacerun:'yes'; font-size:14.0000pt; font-family:'宋体';"  >use&nbsp;liuyan;</span><span style="mso-spacerun:'yes'; font-size:14.0000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-numeric; text-autospace:ideograph-other; text-align:justify;"  ><span style="mso-spacerun:'yes'; font-size:12.0000pt; font-family:'宋体';"  >create&nbsp;table&nbsp;message(title&nbsp;varchar(100),name&nbsp;varchar(20),time&nbsp;varchar(50),content&nbsp;varchar(2000),mail&nbsp;varchar(50));</span><span style="mso-spacerun:'yes'; font-size:12.0000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-size:10.5000pt; font-family:'宋体';"  >2<font face="宋体"  >个</font><font face="Times New Roman"  >JSP</font><font face="宋体"  >页面，</font></span><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-size:10.5000pt; font-family:'宋体';"  ><font face="Times New Roman"  >index.jsp:</font></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-size:10.5000pt; font-family:'宋体';"  ></span><span style="color: rgb(0, 0, 255); font-family: 宋体; font-weight: bold;"  >viewMessages.jsp:</span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-size:10.5000pt; font-family:'宋体';"  ><font face="Times New Roman"  ><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体';"  >3<font face="宋体"  >个</font><font face="Times New Roman"  >message</font><font face="宋体"  >包里的</font><font face="Times New Roman"  >java</font><font face="宋体"  >文件</font><font face="Times New Roman"  >,&nbsp;</font></span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); text-decoration:underline ;font-size:10.5000pt; background:rgb(192,192,192); mso-highlight:rgb(192,192,192); font-family:'Courier New';"  >AddMessageServlet</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); text-decoration:underline ;font-size:10.5000pt; background:rgb(192,192,192); mso-highlight:rgb(192,192,192); font-family:'宋体';"  >.java</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); text-decoration:underline ;font-size:10.5000pt; background:rgb(192,192,192); mso-highlight:rgb(192,192,192); font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); text-decoration:underline ;font-size:10.5000pt; background:rgb(192,192,192); mso-highlight:rgb(192,192,192); font-family:'宋体';"  ><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); text-decoration:underline ;font-size:10.5000pt; background:rgb(192,192,192); mso-highlight:rgb(192,192,192); font-family:'Courier New';"  >MessageVO</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); text-decoration:underline ;font-size:10.5000pt; background:rgb(192,192,192); mso-highlight:rgb(192,192,192); font-family:'宋体';"  >.java</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); text-decoration:underline ;font-size:10.5000pt; background:rgb(192,192,192); mso-highlight:rgb(192,192,192); font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); text-decoration:underline ;font-size:10.5000pt; background:rgb(192,192,192); mso-highlight:rgb(192,192,192); font-family:'宋体';"  ><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); text-decoration:underline ;font-size:10.5000pt; background:rgb(192,192,192); mso-highlight:rgb(192,192,192); font-family:'Courier New';"  >ViewMessageServlet</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); text-decoration:underline ;font-size:10.5000pt; background:rgb(192,192,192); mso-highlight:rgb(192,192,192); font-family:'宋体';"  >.java</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); text-decoration:underline ;font-size:10.5000pt; background:rgb(192,192,192); mso-highlight:rgb(192,192,192); font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); text-decoration:underline ;font-size:10.5000pt; background:rgb(192,192,192); mso-highlight:rgb(192,192,192); font-family:'宋体';"  ><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-size:10.5000pt; font-family:'宋体';"  >web.xml:</span><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  >&lt;?xml&nbsp;version="1.0"&nbsp;encoding="UTF-8"?&gt;</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  >&lt;web-app&nbsp;version="2.4"&nbsp;xmlns="http://java.sun.com/xml/ns/j2ee"</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  >&nbsp;xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&nbsp;xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee&nbsp;&nbsp;&nbsp;http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"&gt;</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&lt;!--message&nbsp;definition--&gt;</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&lt;servlet&gt;</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&nbsp;&lt;display-name&gt;Add&lt;/display-name&gt;</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&nbsp;&lt;servlet-name&gt;AddMessageServlet&lt;/servlet-name&gt;</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&nbsp;&lt;servlet-class&gt;message.AddMessageServlet&lt;/servlet-class&gt;</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&lt;/servlet&gt;</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&lt;servlet&gt;</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&nbsp;&lt;display-name&gt;View&lt;/display-name&gt;</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&nbsp;&lt;servlet-name&gt;ViewMessageServlet&lt;/servlet-name&gt;</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&nbsp;&lt;servlet-class&gt;message.ViewMessageServlet&lt;/servlet-class&gt;</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&lt;/servlet&gt;</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&lt;servlet-mapping&gt;</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&nbsp;&lt;servlet-name&gt;AddMessageServlet&lt;/servlet-name&gt;</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&nbsp;&lt;url-pattern&gt;/AddMessageServlet&lt;/url-pattern&gt;</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&lt;/servlet-mapping&gt;</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&lt;servlet-mapping&gt;</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&nbsp;&lt;servlet-name&gt;ViewMessageServlet&lt;/servlet-name&gt;</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&nbsp;&lt;url-pattern&gt;/ViewMessageServlet&lt;/url-pattern&gt;</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&lt;/servlet-mapping&gt;</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&lt;welcome-file-list&gt;</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&nbsp;&lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&lt;/welcome-file-list&gt;</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&lt;login-config&gt;</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&nbsp;&lt;auth-method&gt;BASIC&lt;/auth-method&gt;</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  >&nbsp;&lt;/login-config&gt;</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  >&lt;/web-app&gt;</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,0); text-decoration:underline ;font-size:10.5000pt; background:rgb(192,192,192); mso-highlight:rgb(192,192,192); font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(255,0,0); font-weight:bold; font-size:10.5000pt; font-family:'宋体';"  >注意的地方：时间格式，我自己手动调节了一下，然后<font face="Times New Roman"  >viewMessages.jsp</font><font face="宋体"  >里：</font></span><span style="mso-spacerun:'yes'; color:rgb(255,0,0); font-weight:bold; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,128,128); font-size:10.5000pt; font-family:'Courier New';"  >&lt;</span><span style="mso-spacerun:'yes'; color:rgb(63,127,127); font-size:10.5000pt; font-family:'Courier New';"  >td</span><span style="mso-spacerun:'yes'; color:rgb(0,128,128); font-size:10.5000pt; font-family:'Courier New';"  >&gt;</span><span style="mso-spacerun:'yes'; color:rgb(191,95,63); font-size:10.5000pt; font-family:'Courier New';"  >&lt;%</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >out.println(</span><span style="mso-spacerun:'yes'; color:rgb(42,0,255); font-size:10.5000pt; font-family:'Courier New';"  >"&lt;a&nbsp;href=mailto:"</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >+ms.getEmail()+</span><span style="mso-spacerun:'yes'; color:rgb(42,0,255); font-size:10.5000pt; font-family:'Courier New';"  >"&gt;"</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >+ms.getEmail()+</span><span style="mso-spacerun:'yes'; color:rgb(42,0,255); font-size:10.5000pt; font-family:'Courier New';"  >"&lt;/a&gt;"</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >);&nbsp;</span><span style="mso-spacerun:'yes'; color:rgb(191,95,63); font-size:10.5000pt; font-family:'Courier New';"  >%&gt;</span><span style="mso-spacerun:'yes'; color:rgb(0,128,128); font-size:10.5000pt; font-family:'Courier New';"  >&lt;/</span><span style="mso-spacerun:'yes'; color:rgb(63,127,127); font-size:10.5000pt; font-family:'Courier New';"  >td</span><span style="mso-spacerun:'yes'; color:rgb(0,128,128); font-size:10.5000pt; font-family:'Courier New';"  >&gt;</span><span style="mso-spacerun:'yes'; color:rgb(0,128,128); font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-size:10.5000pt; font-family:'宋体';"  >一开始写成</span><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,128,128); font-size:10.5000pt; font-family:'Courier New';"  >&lt;</span><span style="mso-spacerun:'yes'; color:rgb(63,127,127); font-size:10.5000pt; font-family:'Courier New';"  >td</span><span style="mso-spacerun:'yes'; color:rgb(0,128,128); font-size:10.5000pt; font-family:'Courier New';"  >&gt;</span><span style="mso-spacerun:'yes'; color:rgb(191,95,63); font-size:10.5000pt; font-family:'Courier New';"  >&lt;%</span><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-size:10.5000pt; font-family:'宋体';"  >=</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >out.println(</span><span style="mso-spacerun:'yes'; color:rgb(42,0,255); font-size:10.5000pt; font-family:'Courier New';"  >"&lt;a&nbsp;href=mailto:"</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >+ms.getEmail()+</span><span style="mso-spacerun:'yes'; color:rgb(42,0,255); font-size:10.5000pt; font-family:'Courier New';"  >"&gt;"</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >+ms.getEmail()+</span><span style="mso-spacerun:'yes'; color:rgb(42,0,255); font-size:10.5000pt; font-family:'Courier New';"  >"&lt;/a&gt;"</span><span style="mso-spacerun:'yes'; color:rgb(0,0,0); font-size:10.5000pt; font-family:'Courier New';"  >)&nbsp;</span><span style="mso-spacerun:'yes'; color:rgb(191,95,63); font-size:10.5000pt; font-family:'Courier New';"  >%&gt;</span><span style="mso-spacerun:'yes'; color:rgb(0,128,128); font-size:10.5000pt; font-family:'Courier New';"  >&lt;/</span><span style="mso-spacerun:'yes'; color:rgb(63,127,127); font-size:10.5000pt; font-family:'Courier New';"  >td</span><span style="mso-spacerun:'yes'; color:rgb(0,128,128); font-size:10.5000pt; font-family:'Courier New';"  >&gt;</span><span style="mso-spacerun:'yes'; color:rgb(0,128,128); font-size:10.5000pt; font-family:'Courier New';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-size:10.5000pt; font-family:'宋体';"  >很难查错！！！</span><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-size:10.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-size:10.5000pt; font-family:'宋体';"  ><br></span></p></span></p></span></p></span></p></font></span></p></div>]]></description>
	    <author><![CDATA[long1]]></author>
	    <comments>http://blog.163.com/lfw2565295@126/blog/static/1220051620123110337594</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/lfw2565295@126/blog/static/1220051620123110337594</guid>
    <pubDate>Sun, 1 Apr 2012 22:03:37 +0800</pubDate>
    <dcterms:modified>2012-04-01T22:03:37+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[(zz) ASP、JSP、PHP三种技术比较]]></title>	
    <link>http://blog.163.com/lfw2565295@126/blog/static/1220051620123163638147</link>
    <description><![CDATA[<div><span style="font-family: 宋体; font-size: 16px; line-height: 28px;"  ><p>目前，最常用的三种动态网页语言有ASP(Active Server Pages),JSP(JavaServer Pages),PHP (Hypertext Preprocessor)。</p><p>&nbsp;&nbsp;&nbsp;&nbsp;<strong>简 介</strong></p></span><span style="font-family: 宋体; font-size: 16px; line-height: 25px;"  >&nbsp; &nbsp; ASP全名Active Server Pages，是一个WEB服务器端的开发环境，利用它可以产生和执行动态的、互动的、高性能的WEB服务应用程序。</span><span style="font-family: 宋体; font-size: 16px; line-height: 28px;"  >ASP采用脚本语言(VBScript,JavaScript)</span><span style="font-family: 宋体; font-size: 16px; line-height: 28px;"  >作为自己的开发语言</span><span style="font-family: 宋体; font-size: 16px; line-height: 28px;"  >。</span><span style="font-family: 宋体; font-size: 16px; line-height: 25px;"  >&nbsp;</span><wbr><span style="font-family: 宋体; font-size: 16px; line-height: 25px;"  >&nbsp;</span><div><span style="font-family: 宋体; font-size: 16px; line-height: 25px;"  >&nbsp; &nbsp; PHP是一种跨平台的服务器端的嵌入式脚本语言。它大量地借用C,Java和Perl语言的语法, 并耦合PHP自己的特性,使WEB开发者能够快速地写出动态产生页面。它支持目前绝大多数数据库。还有一点，PHP是完全免费的，不用花钱，你可以从PHP官方站点(http: //www.php.net)自由下载。而且你可以不受限制地获得源码，甚至可以从中加进你自己需要的特色。</span></div><div><span style="font-family: 宋体; font-size: 16px; line-height: 28px;"  ><p>&nbsp;&nbsp;&nbsp;&nbsp;JSP是Sun公司推出的新一代网站开发语言，Sun公司借助自己在Java上的不凡造诣，将Java从Java应用程序和Java Applet之外，又有新的硕果，就是JSP，Java Server Page。JSP可以在Serverlet和JavaBean的支持下，完成功能强大的站点程序。</p><p>&nbsp;&nbsp;&nbsp;&nbsp;三者都提供在 HTML代码中混合某种程序代码、由语言引擎解释执行程序代码的能力。但JSP代码被编译成 Servlet并由Java虚拟机解释执行，这种编译操作仅在对JSP页面的第一次请求时发生。在ASP 、PHP、JSP环境下，HTML代码主要负责描述信息的显示样式，而程序代码则用来描述处理逻辑。普通的 HTML页面只依赖于Web服务器，而ASP 、PHP、JSP页面需要附加的语言引擎分析和执行程序代码。程序代码的执行结果被重新嵌入到HTML代码中，然后一起发送给浏览器。ASP 、PHP、JSP三者都是面向Web服务器的技术，客户端浏览器不需要任何附加的软件支持。</p><p>　<strong>　技术特点:</strong></p><p>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff"  >ASP:</font></p><p>&nbsp;&nbsp;&nbsp;&nbsp;1. 使用VBScript 、 JScript等简单易懂的脚本语言，结合HTML代码，即可快速地完成网站的应用程序。</p><p>&nbsp;&nbsp;&nbsp;&nbsp;2. 无须compile编译，容易编写，可在服务器端直接执行。</p><p>&nbsp;&nbsp;&nbsp;&nbsp;3. 使用普通的文本编辑器，如Windows的记事本，即可进行编辑设计。</p><p>&nbsp;&nbsp;&nbsp;&nbsp;4. 与浏览器无关(Browser Independence), 客户端只要使用可执行HTML码的浏览器，即可浏览Active Server Pages所设计的网页内容。Active ServerPages 所使用的脚本语言(VBScript 、 Jscript)均在WEB服务器端执行，客户端的浏览器不需要能够执行这些脚本语言。</p><p>&nbsp;&nbsp;&nbsp;&nbsp;5.Active Server Pages能与任何ActiveX scripting语言兼容。除了可使用VB Script或JScript语言来设计外，还通过plug－in的方式，使用由第三方所提供的其它脚本语言，譬如REXX 、Perl 、Tcl等。脚本引擎是处理脚本程序的COM(Component Object Model) 对象。</p><p>&nbsp;&nbsp;&nbsp;&nbsp;6. 可使用服务器端的脚本来产生客户端的脚本。</p><p>&nbsp;&nbsp;&nbsp;&nbsp;7. ActiveX Server Components(ActiveX 服务器组件 )具有无限可扩充性。可以使用Visual Basic 、Java 、Visual C＋＋ 、COBOL等程序设计语言来编写你所需要的ActiveX Server Component 。</p><p>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff"  >PHP:</font></p><p>&nbsp;&nbsp;&nbsp;&nbsp;1 数据库连接</p><p>&nbsp;&nbsp;&nbsp;&nbsp;PHP可以编译成具有与许多数据库相连接的函数。PHP与MySQL是现在绝佳的群组合。你还可以自己编写外围的函数去间接存取数据库。通过这样的途径当你更换使用的数据库时，可以轻松地修改编码以适应这样的变化。PHPLIB就是最常用的可以提供一般事务需要的一系列基库。但PHP提供的数据库接口支持彼此不统一，比如对Oracle, MySQL，Sybase的接口，彼此都不一样。这也是PHP的一个弱点。</p><p><font color="#0000ff"  >&nbsp;&nbsp;&nbsp;&nbsp;JSP:</font></p><p>&nbsp;&nbsp;&nbsp;&nbsp;1.将内容的产生和显示进行分离</p><p>&nbsp;&nbsp;&nbsp;&nbsp;使用JSP技术，Web页面开发人员可以使用HTML或者XML标识来设计和格式化最终页面。使用JSP标识或者小脚本来产生页面上的动态内容。产生内容的逻辑被封装在标识和JavaBeans群组件中，并且捆绑在小脚本中，所有的脚本在服务器端执行。如果核心逻辑被封装在标识和Beans中，那么其它人，如Web管理人员和页面设计者，能够编辑和使用JSP页面，而不影响内容的产生。在服务器端，JSP引擎解释JSP标识，产生所请求的内容（例如，通过存取JavaBeans群组件，使用JDBC技术存取数据库），并且将结果以HTML（或者XML）页面的形式发送回浏览器。这有助于作者保护自己的代码，而又保证任何基于HTML的Web浏览器的完全可用性。</p><p>&nbsp;&nbsp;&nbsp;&nbsp;2.强调可重用的群组件</p><p>&nbsp;&nbsp;&nbsp;&nbsp;绝大多数JSP页面依赖于可重用且跨平台的组件（如：JavaBeans或者Enterprise JavaBeans）来执行应用程序所要求的更为复杂的处理。开发人员能够共享和交换执行普通操作的组件，或者使得这些组件为更多的使用者或者用户团体所使用。基于组件的方法加速了总体开发过程，并且使得各种群组织在他们现有的技能和优化结果的开发努力中得到平衡。</p><p>&nbsp;&nbsp;&nbsp;&nbsp;3.采用标识简化页面开发</p><p>&nbsp;&nbsp;&nbsp;&nbsp;Web页面开发人员不会都是熟悉脚本语言的程序设计人员。JavaServer Page技术封装了许多功能，这些功能是在易用的、与JSP相关的XML标识中进行动态内容产生所需要的。标准的JSP标识能够存取和实例化JavaBeans组件，设定或者检索群组件属性，下载Applet，以及执行用其它方法更难于编码和耗时的功能。通过开发定制化标识库，JSP技术是可以扩展的。今后，第三方开发人员和其它人员可以为常用功能建立自己的标识库。这使得Web页面开发人员能够使用熟悉的工具和如同标识一样的执行特定功能的构件来工作。 JSP技术很容易整合到多种应用体系结构中，以利用现存的工具和技巧，并且扩展到能够支持企业级的分布式应用。作为采用Java技术家族的一部分，以及Java 2EE的一个成员，JSP技术能够支持高度复杂的基于Web的应用。由于JSP页面的内置脚本语言是基于Java程序设计语言的，而且所有的JSP页面都被编译成为Java Servlet，JSP页面就具有Java技术的所有好处，包括健壮的存储管理和安全性。作为Java平台的一部分，JSP拥有Java程序设计语言“一次编写，各处执行”的特点。随着越来越多的供货商将JSP支持加入到他们的产品中，您可以使用自己所选择的服务器和工具，修改工具或服务器并不影响目前的应用。</p></span><span style="font-family: 宋体; font-size: 16px; line-height: 28px;"  ><p><strong>应用范围：</strong></p><p>&nbsp;&nbsp;&nbsp;&nbsp;ASP是Microsoft开发的动态网页语言，也继承了微软产品的一贯传统，只能执行于微软的服务器产品,IIS(Internet Information Server) (windows NT)和PWS(Personal Web Server)(windows 98)上。Unix下也有ChiliSoft的组件来支持ASP，但是ASP本身的功能有限，必须通过ASP＋COM的群组合来扩充，Unix下的COM实现起来非常困难。</p><p>&nbsp;&nbsp;&nbsp;&nbsp;PHP3可在Windows,Unix,Linux的Web服务器上正常执行,还支持IIS,Apache等一般的Web服务器,用户更换平台时,无需变换PHP3代码,可即拿即用。</p><p>&nbsp;&nbsp;&nbsp;&nbsp;JSP同PHP3类似，几乎可以执行于所有平台。如Win NT,Linux,Unix。在NT下IIS通过一个外加服务器，例如JRUN或者ServletExec，就能支持JSP。知名的Web服务器Apache已经能够支持JSP。由于Apache广泛应用在NT、Unix和Linux上，因此JSP有更广泛的执行平台。虽然现在NT操作系统占了很大的市场份额，但是在服务器方面Unix的优势仍然很大，而新崛起的Linux更是来势不小。从一个平台移植到另外一个平台，JSP和JavaBean甚至不用重新编译，因为Java字节码都是标准的与平台无关的。</p><p>&nbsp;&nbsp;&nbsp;&nbsp;<strong>性能比较：</strong></p><p>&nbsp;&nbsp;&nbsp;&nbsp;有人做过试验，对这三种语言分别做回圈性能测试及存取Oracle数据库测试。在循环性能测试中，JSP只用了令人吃惊的四秒钟就结束了20000＊20000的回圈。而ASP、PHP测试的是2000＊2000循环（少一个数量级），却分别用了63秒和84秒。（参考PHPLIB）。 数据库测试中，三者分别对 Oracle 8 进行 1000 次 Insert,Update,Select和Delete： JSP 需要 13 秒，PHP 需要 69 秒，ASP则 需要 73 秒。</p><p>　<strong>　前景分析：</strong></p><p>&nbsp;&nbsp;&nbsp;&nbsp;目前在国内PHP与ASP应用最为广泛。而JSP由于是一种较新的技术，国内采用的较少。但在国外，JSP已经是比较流行的一种技术，尤其是电子商务类的网站，多采用JSP。采用PHP的网站如新浪网（sina）、中国人（Chinaren）等，但由于PHP本身存在的一些缺点，使得它不适合应用于大型电子商务站点，而更适合一些小型的商业站点。首先，PHP缺乏规模支持。其次，缺乏多层结构支持。对于大负荷站点，解决方法只有一个：分布计算。数据库、应用逻辑层、表示逻辑层彼此分开，而且同层也可以根据流量分开，群组成二维数组。而PHP则缺乏这种支持。还有上面提到过的一点，PHP提供的数据库接口支持不统一，这就使得它不适合运用在电子商务中。</p><p>&nbsp;&nbsp;&nbsp;&nbsp;ASP和JSP则没有以上缺陷，ASP可以通过Microsoft Windowsd的COM/DCOM获得ActiveX规模支持，通过DCOM和Transcation Server获得结构支持；JSP可以通过SUN Java的Java Class和EJB获得规模支持，通过EJB/CORBA以及众多厂商的Application Server获得结构支持。三者中，JSP应该是未来发展的趋势。世界上一些大的电子商务解决方案提供商都采用JSP/Servlet。比较出名的如IBM的E－business，它的核心是采用JSP/Servlet的Web Sphere。它们都是通过CGI来提供支持的。但去年10月后它推出了Enfinity，一个采用JSP/Servlet的电子商务Application Server，而且声言不再开发传统软件。</p><p>&nbsp;&nbsp;&nbsp;&nbsp;总之，ASP，PHP,JSP三者都有相当数量的支持者，由此也可以看出三者各有所长。正在学习或使用动态页面的朋友可根据三者的特点选择一种适合自己的语言。</p></span><span style="font-family: 宋体; font-size: 16px; line-height: 28px;"  ><p><a rel="nofollow" href="http://news.xinhuanet.com/internet/2007-04/29/content_6044292.htm"  >http://news.xinhuanet.com/internet/2007-04/29/content_6044292.htm</a></p><p><br></p></span></div></div>]]></description>
	    <author><![CDATA[long1]]></author>
	    <comments>http://blog.163.com/lfw2565295@126/blog/static/1220051620123163638147</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/lfw2565295@126/blog/static/1220051620123163638147</guid>
    <pubDate>Sun, 1 Apr 2012 18:36:38 +0800</pubDate>
    <dcterms:modified>2012-04-01T18:36:38+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[new String(getBytes(ISO-8859-1),GBK) 解决中文乱码问题分析]]></title>	
    <link>http://blog.163.com/lfw2565295@126/blog/static/122005162012229105946600</link>
    <description><![CDATA[<div><span style="font-family: Tahoma, Verdana, STHeiTi, simsun, sans-serif;"  ><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.8em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><font color="#800000"  >转自&nbsp;</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.8em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><font color="#800000"  ><a rel="nofollow" href="http://blog.renren.com/blog/280808345/730757661"  >http://blog.renren.com/blog/280808345/730757661</a></font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.8em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"  ><br></p><p style="color: rgb(51, 51, 51); margin-top: 0px; margin-right: 0px; margin-bottom: 0.8em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.4;"  ><span style="color: rgb(128, 0, 0);"  >用了好几种编码 全是乱码，request.setCharacterEncoding("UTF-8");尝试了好几种</span></p><p style="color: rgb(51, 51, 51); margin-top: 0px; margin-right: 0px; margin-bottom: 0.8em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.4;"  ><span style="color: rgb(128, 0, 0);"  >String newdefrayItem = new String(request.getParameter("newdefrayItem").getBytes("iso-8859-1"),"GBK");也换了几次编码方式，最后是String newdefrayItem = new String(request.getParameter("newdefrayItem").getBytes("iso-8859-1"),"GBK");这样可以。在网上查了下原理，转了过来</span></p><p style="color: rgb(51, 51, 51); margin-top: 0px; margin-right: 0px; margin-bottom: 0.8em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.4;"  >&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0.8em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.4;"  ><font color="#0000ff"  size="4"  >tomcat默认全部都是用ISO-8859-1编码,不管你页面用什么显示,Tomcat最终还是会替你将所有字符转做ISO-8859-1.那么,当在另目标页面再用GBK翻译时就会将本来错的编码翻译成GBK的编码,这时的文字会乱码.&nbsp;</font><br><br><font color="#333333"  >所以需要先将得到"字符"(不管是什么)都先用字节数组表示,且使用ISO-8859-1进行翻译,得到一个在ISO-8859-1编码环境下的字节数组.例如:AB表示成[64,65].然后再用GBK编码这个数组,并翻译成一个字符串.&nbsp;</font><br><br><font color="#333333"  >那么我们可以得到一个编码转换的过程&nbsp;</font><br><font color="#333333"  >假设:GBK码("你")-&gt;URLencode后变成-&gt;(%3F%2F)-&gt;Tomcat自动替你转一次ISO-8859-1-&gt;得到( 23 43 68 23 42 68 每一个符号表示为ISO-8859-1中的一个编码)-&gt;接收页面---&gt;再转一次为ISO-8859-1的Byte数组[23,43,68,23,42,68]---&gt;用GBK再转为可读的文字---&gt;(%3F%2F"----&gt;转为("你")</font></p><p style="color: rgb(51, 51, 51); margin-top: 0px; margin-right: 0px; margin-bottom: 0.8em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.4;"  >&nbsp;</p><p style="color: rgb(51, 51, 51); margin-top: 0px; margin-right: 0px; margin-bottom: 0.8em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.4;"  >除了UTF-16，其它字符集定义时都重复。&nbsp;<br><br>比如汉字“我”，假设它的值是22530（只是假设，具体多少我没查）&nbsp;<br>而日文的“マ”的值也可能是22530(也是假设)或韩文的“?”&nbsp;<br><br>在网络上传输是不能以高字节传输，因为网络底层最后只认无符号char,相当于java中的byte,所以&nbsp;<br>22530这个int要转换为字节数组，&nbsp;<br><br>byte[0] = (22530 &gt;&gt; 8)&amp;0xFF;&nbsp;<br>byte[1] = 22530 &amp;0xFF;&nbsp;<br>具体多少我没算，假设是byte[125，231]&nbsp;<br><br>这样的字节传到服务端到是表示汉字“我”还是日文的“マ”还是其它狗屁？&nbsp;<br>一般通讯协议中会告诉对字符集，比如HTTP在请求时告诉服务端：&nbsp;<br>ContentType="xxxxxxxxxx";charset="GKB";&nbsp;<br>这时服务端就知道现在接收到的［125，231］是GKB的“我”而不是其它文字。&nbsp;<br><br>上面是标准的通信过程。但如果有些水平很差的程序员在提交请求时没有通知服务端字符集，那服务端就没办法了。&nbsp;<br>只好按最常用的字符集来猜一个默认的。&nbsp;<br><br>这还不错，最要命的是写服务器的程序员水平和见识很差时，就要命了。就象写老版本的TOMCAT的程序员，他自己生在西方，以为全世界所有人都用的是26个字母加一些符号，所以他不管客户端提交什么都按ISO-8859-1来算，结果可想而知。&nbsp;<br><br>没办法，谁让我们用GBK的人不会写tomcat呢，只好先把让那个差劲的程序员错误生成的String用ISO-8859-1还原成&nbsp;<br>［125，231］，再重新用GKB生成String.</p><p style="color: rgb(51, 51, 51); margin-top: 0px; margin-right: 0px; margin-bottom: 0.8em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.4;"  >&nbsp;</p><p style="color: rgb(51, 51, 51); margin-top: 0px; margin-right: 0px; margin-bottom: 0.8em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.4;"  >&nbsp;</p><p style="color: rgb(51, 51, 51); margin-top: 0px; margin-right: 0px; margin-bottom: 0.8em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.4;"  >用于得到服务器传来的字符重新生成GBK编码</p></span><wbr></div>]]></description>
	    <author><![CDATA[long1]]></author>
	    <comments>http://blog.163.com/lfw2565295@126/blog/static/122005162012229105946600</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/lfw2565295@126/blog/static/122005162012229105946600</guid>
    <pubDate>Thu, 29 Mar 2012 10:59:46 +0800</pubDate>
    <dcterms:modified>2012-03-29T10:59:46+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[MyEclipse 打包和发布]]></title>	
    <link>http://blog.163.com/lfw2565295@126/blog/static/122005162012228103633938</link>
    <description><![CDATA[<div><div class="Section0"  style="layout-grid:15.6000pt;"  ><p style="margin-bottom:0pt; margin-top:0pt; text-align:center;"  ><span><a rel="nofollow" href="http://blog.csdn.net/wyzsc/article/details/6197286"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:normal; font-style:normal; font-size:24.0000pt; font-family:'黑体';"  >MyEclipse&nbsp;打包和发布</span></a></span></p><p style="margin-bottom:0pt; margin-top:0pt;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other;"  ><span style="mso-spacerun:'yes'; font-weight:bold; font-size:12.5000pt; font-family:'Times New Roman';"  >开发环境</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other;"  ><span style="mso-spacerun:'yes'; font-size:12.5000pt; font-family:'Times New Roman';"  >Myeclipse</span><span style="mso-spacerun:'yes'; font-size:12.5000pt; font-family:'宋体';"  >8.5</span><span style="mso-spacerun:'yes'; font-size:12.5000pt; font-family:'宋体';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other;"  ><span style="mso-spacerun:'yes'; font-size:12.5000pt; font-family:'Times New Roman';"  >jdk1.6</span><span style="mso-spacerun:'yes'; font-size:12.5000pt; font-family:'Times New Roman';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other;"  ><span style="mso-spacerun:'yes'; font-size:12.5000pt; font-family:'Times New Roman';"  >Tomcat</span><span style="mso-spacerun:'yes'; font-size:12.5000pt; font-family:'宋体';"  >&nbsp;7.*</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  >&nbsp;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other;"  ><span style="mso-spacerun:'yes'; font-weight:bold; font-size:12.5000pt; font-family:'Times New Roman';"  >实验方法一：简单的内部测试的发布方法，不用打包步骤</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  >使用<font face="Times New Roman"  >myeclipse</font><font face="宋体"  >时，在本机自动编译且运行正常后，找到</font><font face="Times New Roman"  >Tomcat</font><font face="宋体"  >目录的相关位置，如</font><font face="Times New Roman"  >C:/Tomcat6.0/work/Catalina/localhost/_/org/apache/jsp</font><font face="宋体"  >，</font></span><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-size:10.5000pt; font-family:'Times New Roman';"  >下一级目录就是<font face="Times New Roman"  >server.xml</font><font face="宋体"  >中配置的子目录了，复制内容该子目录的全部内容到测试服务器的同样目录下</font></span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  >，启动测试服务器的<font face="Times New Roman"  >tomcat</font><font face="宋体"  >，就能看到对应的网页了。</font></span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  >说明：</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  >1<font face="宋体"  >、此方法，用户可以看到源文件，只能用于内部测试。</font></span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  >2<font face="宋体"  >、本人清空</font><font face="Times New Roman"  >work</font><font face="宋体"  >目录，在</font><font face="Times New Roman"  >myesclipse</font><font face="宋体"  >启动</font><font face="Times New Roman"  >Tomcat</font><font face="宋体"  >时，会自动生成各下级目录和对应的内容，证明是自动生成的。</font></span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other;"  ><span style="mso-spacerun:'yes'; font-weight:bold; font-size:12.5000pt; font-family:'Times New Roman';"  >实验方法二：</span><span style="mso-spacerun:'yes'; font-weight:bold; font-size:18.0000pt; font-family:'Times New Roman';"  >MyEclipse<font face="宋体"  >生成</font><font face="Times New Roman"  >WAR</font><font face="宋体"  >包并在</font><font face="Times New Roman"  >Tomcat</font><font face="宋体"  >下部署发布</font></span><span style="mso-spacerun:'yes'; font-weight:bold; font-size:12.5000pt; font-family:'Times New Roman';"  ><br></span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  >首先是使用<font face="Times New Roman"  >MyEclipse</font><font face="宋体"  >将</font><font face="Times New Roman"  >web</font><font face="宋体"  >项目打包，右键选中项目，选择</font><font face="Times New Roman"  >export</font><font face="宋体"  >。</font></span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  ><br></span><span style="mso-spacerun:'yes'; color:rgb(255,0,0); font-weight:bold; font-size:14.0000pt; font-family:'Times New Roman';"  >弹出<font face="Times New Roman"  >Export</font><font face="宋体"  >的</font><font face="Times New Roman"  >select</font><font face="宋体"  >窗体，选择</font><font face="Times New Roman"  >Java&nbsp;EE&nbsp;</font><font face="宋体"  >的</font><font face="Times New Roman"  >WAR&nbsp;file(myeclipse)</font><font face="宋体"  >选项，然后选择工程名称和路径，单击完成就可以了。</font></span><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-size:10.5000pt; font-family:'Times New Roman';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other;"  ><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-size:10.5000pt; font-family:'Times New Roman';"  >打包完成以后我们将<font face="Times New Roman"  >war</font><font face="宋体"  >放到</font><font face="Times New Roman"  >tomcat</font><font face="宋体"  >的</font><font face="Times New Roman"  >webapps</font><font face="宋体"  >目录下，并设置</font><font face="Times New Roman"  >server.xml</font><font face="宋体"  >文件；设置方法，在本人的其它文章中有介绍。</font></span><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-size:10.5000pt; font-family:'Times New Roman';"  ><br></span><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-size:10.5000pt; font-family:'Times New Roman';"  >然后运行<font face="Times New Roman"  >tomcat</font><font face="宋体"  >，并输入项目的</font><font face="Times New Roman"  >url</font><font face="宋体"  >就可以了。</font></span><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-size:10.5000pt; font-family:'Times New Roman';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  >说明，</span><span style="mso-spacerun:'yes'; font-weight:bold; font-size:12.5000pt; font-family:'Times New Roman';"  >对外此方法可用</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  >，即使包括了</span><span style="mso-spacerun:'yes'; font-size:12.5000pt; font-family:'Times New Roman';"  >外部<font face="Times New Roman"  >JAR</font><font face="宋体"  >包</font></span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other;"  ><span style="mso-spacerun:'yes'; font-size:12.5000pt; font-family:'Times New Roman';"  >补充，个人习惯是将<font face="Times New Roman"  >war</font><font face="宋体"  >包用</font><font face="Times New Roman"  >rar</font><font face="宋体"  >解压到</font></span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  >webapps<font face="宋体"  >目录下的指定目录中</font><font face="Times New Roman"  >(</font><font face="宋体"  >如</font><font face="Times New Roman"  >abc)</font><font face="宋体"  >，然后在</font><font face="Times New Roman"  >server.xml</font><font face="宋体"  >文件中，设置</font><font face="Times New Roman"  >docBase</font><font face="宋体"  >项为该目录</font><font face="Times New Roman"  >(</font><font face="宋体"  >如</font><font face="Times New Roman"  >abc)</font><font face="宋体"  >，再启动</font><font face="Times New Roman"  >tomcat</font><font face="宋体"  >。</font></span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  >说明，<font face="Times New Roman"  >server.xml</font><font face="宋体"  >调整后，</font><font face="Times New Roman"  >tomcat</font><font face="宋体"  >必须重新启动，配置文件才起作用。</font></span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other;"  ><span style="mso-spacerun:'yes'; font-weight:bold; font-size:12.5000pt; font-family:'Times New Roman';"  >实验方法三：指定目录生成<font face="Times New Roman"  >jar</font><font face="宋体"  >包</font></span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other;"  ><span style="mso-spacerun:'yes'; font-size:12.5000pt; font-family:'Times New Roman';"  >在工程内的指定目录（<font face="Times New Roman"  >CS</font><font face="宋体"  >或者</font><font face="Times New Roman"  >BS</font><font face="宋体"  >结构</font><font face="Times New Roman"  >)</font><font face="宋体"  >上单击右键，选择</font><font face="Times New Roman"  >Export</font><font face="宋体"  >选项，弹出</font><font face="Times New Roman"  >Export</font><font face="宋体"  >的</font><font face="Times New Roman"  >select</font><font face="宋体"  >窗体，选择</font><font face="Times New Roman"  >Java&nbsp;</font><font face="宋体"  >的</font><font face="Times New Roman"  >Jar&nbsp;file</font><font face="宋体"  >选项，然后选择工程名称和路径等，单击完成就可以了。</font></span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other;"  ><span style="mso-spacerun:'yes'; font-weight:bold; font-size:12.5000pt; font-family:'Times New Roman';"  >实验方法四：用<font face="Times New Roman"  >MyEclipse</font><font face="宋体"  >视图生成并自动布署</font></span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  >&nbsp;菜单<font face="Times New Roman"  >window--show&nbsp;view</font><font face="宋体"  >，选择</font><font face="Times New Roman"  >package&nbsp;exlorer</font><font face="宋体"  >视图，在此视图中，在要生成的项目上右键，选择</font><font face="Times New Roman"  >add&nbsp;and&nbsp;remove&nbsp;project&nbsp;deployments</font><font face="宋体"  >，弹出窗体中，单击</font><font face="Times New Roman"  >add</font><font face="宋体"  >按钮，弹出创建新部署对话框，在</font><font face="Times New Roman"  >server</font><font face="宋体"  >下拉框中选择</font><font face="Times New Roman"  >tomcat&nbsp;6.x</font><font face="宋体"  >服务器；选项是生成开发过程的部署</font><font face="Times New Roman"  >(wlp)</font><font face="宋体"  >，还是最终发版的部署</font><font face="Times New Roman"  >(war)</font><font face="宋体"  >；系统会自动部署在</font><font face="Times New Roman"  >tomcat</font><font face="宋体"  >的</font><font face="Times New Roman"  >webapps</font><font face="宋体"  >目录，系统允许删除此部署，允许重新部署。</font></span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  >说明，此方法最简单，且满足了内部测试和发版的要求。</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  ><br></span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  ><br></span><span style="mso-spacerun:'yes'; font-size:12.5000pt; font-family:'Times New Roman';"  >注意事项</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other;"  ><span style="mso-spacerun:'yes'; font-size:12.5000pt; font-family:'Times New Roman';"  >发布后与开发版不一样，直接用</span><span><a rel="nofollow" href="http://localhost:8080/"  ><span style="mso-spacerun:'yes'; color:rgb(51,102,153); font-size:12.5000pt; font-family:'Times New Roman';"  >http://localhost:8080</span></a></span><span style="mso-spacerun:'yes'; font-size:12.5000pt; font-family:'Times New Roman';"  >访问时，显示的是<font face="Times New Roman"  >tomcat</font><font face="宋体"  >的</font><font face="Times New Roman"  >root</font><font face="宋体"  >下的</font><font face="Times New Roman"  >index.jsp</font><font face="宋体"  >，即使你的目录下有此文件也是显示</font><font face="Times New Roman"  >tomcat</font><font face="宋体"  >的，解决方法，用不同的端口号，且地址改为访问</font><font face="Times New Roman"  >IP</font><font face="宋体"  >地址，即使本机，也用</font></span><span><a rel="nofollow" href="http://127.0.0.1:8080/"  ><span style="mso-spacerun:'yes'; color:rgb(51,102,153); font-size:12.5000pt; font-family:'Times New Roman';"  >http://127.0.0.1:8080</span></a></span><span style="mso-spacerun:'yes'; font-size:12.5000pt; font-family:'Times New Roman';"  >，就正常了。</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  ></span></p><p style="margin-bottom:0pt; margin-top:0pt; text-autospace:ideograph-other;"  ><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  >自动获取<font face="Times New Roman"  >IP</font><font face="宋体"  >时，检查本机的</font><font face="Times New Roman"  >IP</font><font face="宋体"  >地址的方法，运行</font><font face="Times New Roman"  >cmd</font><font face="宋体"  >，输入</font><font face="Times New Roman"  >ipconfig</font><font face="宋体"  >，本地连接中会显示现在的</font><font face="Times New Roman"  >IP</font><font face="宋体"  >地址。</font></span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Times New Roman';"  ></span></p></div></div>]]></description>
	    <author><![CDATA[long1]]></author>
	    <comments>http://blog.163.com/lfw2565295@126/blog/static/122005162012228103633938</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/lfw2565295@126/blog/static/122005162012228103633938</guid>
    <pubDate>Wed, 28 Mar 2012 22:36:33 +0800</pubDate>
    <dcterms:modified>2012-03-28T22:36:33+08:00</dcterms:modified>
  </item>    
 </channel>
</rss>
