﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>IT博客-chlclan-随笔分类-DS study</title><link>http://www.cnitblog.com/chlclan/category/3039.html</link><description /><language>zh-cn</language><lastBuildDate>Wed, 28 Sep 2011 02:30:47 GMT</lastBuildDate><pubDate>Wed, 28 Sep 2011 02:30:47 GMT</pubDate><ttl>60</ttl><item><title>二叉树相关</title><link>http://www.cnitblog.com/chlclan/archive/2006/08/16/15394.html</link><dc:creator>Enjoy Life</dc:creator><author>Enjoy Life</author><pubDate>Wed, 16 Aug 2006 12:47:00 GMT</pubDate><guid>http://www.cnitblog.com/chlclan/archive/2006/08/16/15394.html</guid><wfw:comment>http://www.cnitblog.com/chlclan/comments/15394.html</wfw:comment><comments>http://www.cnitblog.com/chlclan/archive/2006/08/16/15394.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/chlclan/comments/commentRss/15394.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/chlclan/services/trackbacks/15394.html</trackback:ping><description><![CDATA[
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">#include &lt;stdio.h&gt;<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /?><o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">#include &lt;stdlib.h&gt;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<o:p>
								<font face="宋体"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">typedef struct bitnode{<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 1">    </span>char data;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 1">    </span>struct bitnode *lchild, *rchild;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">}bitnode, *bitree;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<o:p>
								<font face="宋体"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">void createbitree(bitnode **t, int *n){<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 1">    </span>char x;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 1">    </span>bitnode *q;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<o:p>
								<font face="宋体"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 1">    </span>*n=*n+1;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 1">    </span>printf("\n Input<span style="mso-spacerun: yes">  </span>%d<span style="mso-spacerun: yes">  </span>DATA:",*n);<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 1">    </span>x=getchar();<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 1">    </span>if(x!='\n') getchar();<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<o:p>
								<font face="宋体"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 1">    </span>if (x=='\n')<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 1">    </span>return;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<o:p>
								<font face="宋体"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 1">    </span>q=(bitnode*)malloc(sizeof(bitnode));<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 1">    </span>q-&gt;data=x;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 1">    </span>q-&gt;lchild=NULL;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 1">    </span>q-&gt;rchild=NULL;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 1">    </span>*t=q;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<o:p>
								<font face="宋体"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 1">    </span>printf(" This Address is:<span style="mso-spacerun: yes">   </span>%o,<span style="mso-spacerun: yes">    </span>Data is:<span style="mso-spacerun: yes">  </span>%c,\n<span style="mso-spacerun: yes">      </span>Left Pointer is:<span style="mso-spacerun: yes">   </span>%o,<span style="mso-spacerun: yes">       </span>Right Pointer is:<span style="mso-spacerun: yes">  </span>%o",q,q-&gt;data,q-&gt;lchild,q-&gt;rchild);<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<o:p>
								<font face="宋体"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 1">    </span>createbitree(&amp;q-&gt;lchild,n);<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 1">    </span>createbitree(&amp;q-&gt;rchild,n);<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 1">    </span>return;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">}<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<o:p>
								<font face="宋体"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">void visit(bitnode *e)<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">{<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">printf("<span style="mso-spacerun: yes">  </span>Address:<span style="mso-spacerun: yes">  </span>%o,<span style="mso-spacerun: yes">  </span>Data:<span style="mso-spacerun: yes">  </span>%c,<span style="mso-spacerun: yes">  </span>Left Pointer:<span style="mso-spacerun: yes">  </span>%o,<span style="mso-spacerun: yes">  </span>Right Pointer:<span style="mso-spacerun: yes">  </span>%o\n",e,e-&gt;data,e-&gt;lchild,e-&gt;rchild);<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">}<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<o:p>
								<font face="宋体"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">void preordertraverse(bitnode *t){<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 1">    </span>if(t){<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 2">        </span>visit(t);<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 2">        </span>preordertraverse(t-&gt;lchild);<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 2">        </span>preordertraverse(t-&gt;rchild);<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 2">        </span>return;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 1">    </span>}<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 1">    </span>else<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 2">        </span>return;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">}<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<o:p>
								<font face="宋体"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">void inordertraverse(bitnode *t){<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 1">    </span>if(t){<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 2">        </span>inordertraverse(t-&gt;lchild);<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 2">        </span>visit(t);<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 2">        </span>inordertraverse(t-&gt;rchild);<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 2">        </span>return;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 1">    </span>}<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 1">    </span>else<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 2">        </span>return;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">}<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<o:p>
								<font face="宋体"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">void postordertraverse(bitnode *t){<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 1">    </span>if(t){<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 2">        </span>postordertraverse(t-&gt;lchild);<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 2">        </span>postordertraverse(t-&gt;rchild);<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 2">        </span>visit(t);<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 1">    </span>}<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">}<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<o:p>
								<font face="宋体"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">main()<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">{<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">bitnode *t; int count=0;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">int n=0;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<o:p>
								<font face="宋体"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">printf("\n<span style="mso-spacerun: yes">  </span>Please input TREE Data:\n");<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">createbitree(&amp;t,&amp;n);<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">preordertraverse(t);<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">inordertraverse(t);<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">postordertraverse(t);<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<o:p>
								<font face="宋体"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">}<o:p></o:p></font>
				</span>
		</p>
<img src ="http://www.cnitblog.com/chlclan/aggbug/15394.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/chlclan/" target="_blank">Enjoy Life</a> 2006-08-16 20:47 <a href="http://www.cnitblog.com/chlclan/archive/2006/08/16/15394.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>二叉书的建立（解决无法结束二叉书的建立函数）</title><link>http://www.cnitblog.com/chlclan/archive/2006/08/16/15392.html</link><dc:creator>Enjoy Life</dc:creator><author>Enjoy Life</author><pubDate>Wed, 16 Aug 2006 12:12:00 GMT</pubDate><guid>http://www.cnitblog.com/chlclan/archive/2006/08/16/15392.html</guid><wfw:comment>http://www.cnitblog.com/chlclan/comments/15392.html</wfw:comment><comments>http://www.cnitblog.com/chlclan/archive/2006/08/16/15392.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/chlclan/comments/commentRss/15392.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/chlclan/services/trackbacks/15392.html</trackback:ping><description><![CDATA[
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">#include &lt;stdio.h&gt;<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /?><o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">#include &lt;stdlib.h&gt;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<o:p>
								<font face="Courier New"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">typedef struct bitnode{<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">
								<span style="mso-tab-count: 1">    </span>char data;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">
								<span style="mso-tab-count: 1">    </span>struct bitnode *lchild, *rchild;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">}bitnode, *bitree;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<o:p>
								<font face="Courier New"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">void createbitree(bitnode **t, int *n){<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">
								<span style="mso-tab-count: 1">    </span>char x;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">
								<span style="mso-tab-count: 1">    </span>bitnode *q;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<o:p>
								<font face="Courier New"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">
								<span style="mso-tab-count: 1">    </span>*n=*n+1;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">
								<span style="mso-tab-count: 1">    </span>printf("\n Input<span style="mso-spacerun: yes">  </span>%d<span style="mso-spacerun: yes">  </span>DATA:",*n);<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">
								<span style="mso-tab-count: 1">    </span>x=getchar();<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">
								<span style="mso-tab-count: 1">    </span>if(x!='\n') getchar();<br />   //后面的getchar函数是用来消除每次输入完字符后按的空格键（\n）</font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<o:p>
								<font face="Courier New"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">
								<span style="mso-tab-count: 1">    </span>if (x=='\n')<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">
								<span style="mso-tab-count: 1">    </span>return;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<o:p>
								<font face="Courier New"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">
								<span style="mso-tab-count: 1">    </span>q=(bitnode*)malloc(sizeof(bitnode));<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">
								<span style="mso-tab-count: 1">    </span>q-&gt;data=x;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">
								<span style="mso-tab-count: 1">    </span>q-&gt;lchild=NULL;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">
								<span style="mso-tab-count: 1">    </span>q-&gt;rchild=NULL;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">
								<span style="mso-tab-count: 1">    </span>*t=q;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<o:p>
								<font face="Courier New"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">
								<span style="mso-tab-count: 1">    </span>printf(" This Address is:<span style="mso-spacerun: yes">   </span>%o,<span style="mso-spacerun: yes">    </span>Data is:<span style="mso-spacerun: yes">  </span>%c,\n<span style="mso-spacerun: yes">      </span>Left Pointer is:<span style="mso-spacerun: yes">   </span>%o,<span style="mso-spacerun: yes">       </span>Right Pointer is:<span style="mso-spacerun: yes">  </span>%o",q,q-&gt;data,q-&gt;lchild,q-&gt;rchild);<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<o:p>
								<font face="Courier New"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">
								<span style="mso-tab-count: 1">    </span>createbitree(&amp;q-&gt;lchild,n);<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">
								<span style="mso-tab-count: 1">    </span>createbitree(&amp;q-&gt;rchild,n);<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">
								<span style="mso-tab-count: 1">    </span>return;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">}<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<o:p>
								<font face="Courier New"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<o:p>
								<font face="Courier New"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">main()<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">{<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">bitnode *t; int count=0;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">int n=0;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<o:p>
								<font face="Courier New"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">printf("\n<span style="mso-spacerun: yes">  </span>Please input TREE Data:\n");<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">createbitree(&amp;t,&amp;n);<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<o:p>
								<font face="Courier New"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">}<o:p></o:p></font>
				</span>
		</p>
		<p>
				<font face="Courier New">注意二叉树的建立必须在所有的叶子节点上lchild和rchild都输入\n才能完成整个二叉树的建立！</font>
		</p>
<img src ="http://www.cnitblog.com/chlclan/aggbug/15392.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/chlclan/" target="_blank">Enjoy Life</a> 2006-08-16 20:12 <a href="http://www.cnitblog.com/chlclan/archive/2006/08/16/15392.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>链表操作的正确与错误的算法 重要</title><link>http://www.cnitblog.com/chlclan/archive/2006/06/22/12710.html</link><dc:creator>Enjoy Life</dc:creator><author>Enjoy Life</author><pubDate>Thu, 22 Jun 2006 14:13:00 GMT</pubDate><guid>http://www.cnitblog.com/chlclan/archive/2006/06/22/12710.html</guid><wfw:comment>http://www.cnitblog.com/chlclan/comments/12710.html</wfw:comment><comments>http://www.cnitblog.com/chlclan/archive/2006/06/22/12710.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/chlclan/comments/commentRss/12710.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/chlclan/services/trackbacks/12710.html</trackback:ping><description><![CDATA[
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Garamond">通过一个子函数的内部来对单链表的头指针做修改：<span lang="EN-US"><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /?><o:p></o:p></span></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<font face="Garamond">
						<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">1</span>
						<span style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">、以下代码不能达到预期的效果：<span lang="EN-US"><o:p></o:p></span></span>
				</font>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Garamond">typedef int ElemType;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Garamond">typedef struct ListNode {<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Garamond">
								<span style="mso-tab-count: 1">    </span>ElemType data;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Garamond">
								<span style="mso-tab-count: 1">    </span>struct LNode *next;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Garamond">}LNode;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<o:p>
								<font face="Garamond"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Garamond">int BadInsert(LNode *head)<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Garamond">{<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Garamond">
								<span style="mso-tab-count: 1">    </span>LNode *NewL;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Garamond">
								<span style="mso-tab-count: 1">    </span>NewL = (LNode *)malloc(sizeof(LNode));<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Garamond">
								<span style="mso-tab-count: 1">    </span>if(!NewL){<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Garamond">
								<span style="mso-tab-count: 2">        </span>printf("Malloc ERROR\n");<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Garamond">
								<span style="mso-tab-count: 2">        </span>return ERROR;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Garamond">
								<span style="mso-tab-count: 1">    </span>}<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Garamond">
								<span style="mso-tab-count: 1">    </span>NewL-&gt;next = head;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Garamond">
								<span style="mso-tab-count: 1">    </span>
								<o:p>
								</o:p>
						</font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Garamond">
								<span style="mso-tab-count: 1">    </span>/*Incorrectly updates local copy of head.<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Garamond">
								<span style="mso-tab-count: 1">    </span>*Calling code retains the old values for the first element<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Garamond">
								<span style="mso-tab-count: 1">    </span>*pointer, so it now points at the second element of the list<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Garamond">
								<span style="mso-tab-count: 1">    </span>*/<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<font face="Garamond">
						<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
								<span style="mso-tab-count: 1">    </span>/*</span>
						<span style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">下面的代码只是修改了<span lang="EN-US">head</span>的一个副本，并没有修改实际传进来的<span lang="EN-US"><o:p></o:p></span></span>
				</font>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<font face="Garamond">
						<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
								<span style="mso-tab-count: 1">    </span>*</span>
						<span style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">参数<span lang="EN-US">head</span>，从而并没有达到预期的效果<span lang="EN-US"><o:p></o:p></span></span>
				</font>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Garamond">
								<span style="mso-tab-count: 1">    </span>*/<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Garamond">
								<span style="mso-tab-count: 1">    </span>head = NewL;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Garamond">
								<span style="mso-tab-count: 1">    </span>return 1;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Garamond">}<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<o:p>
								<font face="Garamond"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<font face="Garamond">
						<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">2.</span>
						<span style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">正确的代码<span lang="EN-US"><o:p></o:p></span></span>
				</font>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<o:p>
								<font face="Garamond"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Garamond">int Insert(LNode **head)<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Garamond">{<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Garamond">
								<span style="mso-tab-count: 1">    </span>LNode *NewL;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Garamond">
								<span style="mso-tab-count: 1">    </span>NewL = (LNode *)malloc(sizeof(LNode));<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Garamond">
								<span style="mso-tab-count: 1">    </span>if(!NewL)<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Garamond">
								<span style="mso-tab-count: 2">        </span>return 0;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Garamond">
								<span style="mso-tab-count: 1">    </span>NewL-&gt;next = *head;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Garamond">
								<span style="mso-tab-count: 1">    </span>/* *head gives the calling function's head pointer, so<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Garamond">
								<span style="mso-tab-count: 1">    </span>*the change is not lost when this function returns<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Garamond">
								<span style="mso-tab-count: 1">    </span>*/<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Garamond">
								<span style="mso-tab-count: 1">    </span>*head = NewL;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Garamond">
								<span style="mso-tab-count: 1">    </span>return 1;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Garamond">}<o:p></o:p></font>
				</span>
		</p>
<img src ="http://www.cnitblog.com/chlclan/aggbug/12710.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/chlclan/" target="_blank">Enjoy Life</a> 2006-06-22 22:13 <a href="http://www.cnitblog.com/chlclan/archive/2006/06/22/12710.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>双链表的插入代码实现</title><link>http://www.cnitblog.com/chlclan/archive/2006/06/21/12655.html</link><dc:creator>Enjoy Life</dc:creator><author>Enjoy Life</author><pubDate>Wed, 21 Jun 2006 13:46:00 GMT</pubDate><guid>http://www.cnitblog.com/chlclan/archive/2006/06/21/12655.html</guid><wfw:comment>http://www.cnitblog.com/chlclan/comments/12655.html</wfw:comment><comments>http://www.cnitblog.com/chlclan/archive/2006/06/21/12655.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/chlclan/comments/commentRss/12655.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/chlclan/services/trackbacks/12655.html</trackback:ping><description><![CDATA[通过近20分钟的debug,终于把这个简单的代码实现,真是郁闷啊,发现指针的操作很容易出错.<br /><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'">//ListInsert_Dul.cpp<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /?><o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'">//This program is to insert a node into the DuLinkList<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"># include &lt;stdlib.h&gt;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"># include &lt;malloc.h&gt;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"># include &lt;iostream.h&gt;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"># include &lt;conio.h&gt;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><o:p> </o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"># define INIT_LENGTH 10<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"># define OK 1<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"># define ERROR 0<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'">typedef int ElemType;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><o:p> </o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'">typedef struct DuLNode <span style="mso-tab-count: 2">     </span>//define DuLinkList structure<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'">{<span style="mso-tab-count: 1">   </span>int data;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span>struct DuLNode *prior;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span>struct DuLNode *next;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'">}DuLNode,*DuLinkList;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><o:p> </o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><o:p> </o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><o:p> </o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'">int DuLinkLength(DuLNode *L){<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span>DuLNode *p;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span>int i = 0;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span>p = L;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span>if(!L)<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 2">       </span>return 0;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span>else {<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 2">       </span>while(p){<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 2">       </span><span style="mso-tab-count: 1">    </span>i++;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 3">           </span>p = p-&gt;next;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 2">       </span>}<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span>}<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span>return i;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'">}<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><o:p> </o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'">DuLNode *GetElemP_DuL(DuLNode *L, int i){<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span>int j;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span>int k = 1;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span>DuLNode *p;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span>p = L;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span>j = DuLinkLength(L);<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span><o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span>/*i=i±íÊ¾²åÔÚË«Á´±íµÄµÚÒ»¸öÔªËØÎ»ÖÃ£¬j+1±íÊ¾<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span>*²åÔÚ×îºóÒ»¸öÔªËØÖ®ºó<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span>*/<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span>if(i&lt;2||i&gt;j+1){<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 2">       </span>return NULL;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span>}<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span>else {<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 2">       </span>while(k &lt; i-1){<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 3">           </span>k++;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 3">           </span>p = p-&gt;next;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 2">       </span>}<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 2">       </span>return p;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span>}<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'">}<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><o:p> </o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'">int ListInsert_DuL(DuLNode *L, int i, ElemType e){<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span>DuLNode *p, *s;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span>if(!(p = GetElemP_DuL(L,i)))<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 2">       </span>return ERROR;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span>if(!(s = (DuLNode *)malloc(sizeof(DuLNode))))<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 2">       </span>return ERROR;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span>s-&gt;data = e;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span>s-&gt;prior = p;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span>s-&gt;next = p-&gt;next;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span>p-&gt;next = s;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span>return OK;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'">}<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><o:p> </o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><o:p> </o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><o:p> </o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'">void main()<span style="mso-spacerun: yes">        </span><span style="mso-tab-count: 2">       </span>//main() function<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'">{<span style="mso-spacerun: yes">    </span>int i,j,e;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-spacerun: yes">     </span>//DuLNode node[10];<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-spacerun: yes">     </span>DuLNode *L,*p;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-spacerun: yes">     </span>int array[10]={5,8,12,18,25,30,37,46,51,89};<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-spacerun: yes">     </span>L=(DuLNode *)malloc(sizeof(DuLNode));<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-spacerun: yes">     </span>L-&gt;next=NULL;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span><span style="mso-spacerun: yes"> </span>L-&gt;data = array[0];<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-spacerun: yes">     </span>L-&gt;prior=NULL;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-spacerun: yes">     </span>for (i=1;i&lt;=9;i++)<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-spacerun: yes">     </span>{<span style="mso-tab-count: 1">  </span><o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span><span style="mso-spacerun: yes"> </span>p=(DuLNode *)malloc(sizeof(DuLNode));<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span><span style="mso-spacerun: yes"> </span>p-&gt;data=array[i];<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span><span style="mso-spacerun: yes"> </span>L-&gt;next = p;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span><span style="mso-spacerun: yes"> </span>p-&gt;prior = L;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span><span style="mso-spacerun: yes"> </span>p-&gt;next = NULL;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span><span style="mso-spacerun: yes"> </span>L = L-&gt;next;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span><span style="mso-spacerun: yes"> </span><o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span><span style="mso-spacerun: yes"> </span>/*<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span><span style="mso-spacerun: yes"> </span>p-&gt;next=L-&gt;next;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span><span style="mso-spacerun: yes"> </span>p-&gt;next-&gt;prior=p;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span><span style="mso-spacerun: yes"> </span>L-&gt;next=p;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span><span style="mso-spacerun: yes"> </span>*/<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-spacerun: yes">     </span>}<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-spacerun: yes">    </span><o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span><span style="mso-spacerun: yes"> </span>for(i=1;i&lt;=9;i++)<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 2">       </span><span style="mso-spacerun: yes"> </span>L=L-&gt;prior;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-spacerun: yes">     </span>p = L;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-spacerun: yes">     </span><o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-spacerun: yes">     </span>cout&lt;&lt;endl&lt;&lt;endl&lt;&lt;"ListInsert_Dul.cpp";<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-spacerun: yes">     </span>cout&lt;&lt;endl&lt;&lt;"==================";<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-spacerun: yes">     </span>cout &lt;&lt;endl&lt;&lt;endl&lt;&lt;"The old DuLNode is : ";<span style="mso-spacerun: yes">  </span>//output the old DuLinkList<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-spacerun: yes">     </span>for(j=0;j&lt;10;j++)<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-spacerun: yes">     </span>{<span style="mso-spacerun: yes">   </span><o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span><span style="mso-spacerun: yes"> </span>cout&lt;&lt;p-&gt;data&lt;&lt;" ";<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span><span style="mso-spacerun: yes"> </span>p=p-&gt;next;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-spacerun: yes">     </span>}<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-spacerun: yes">     </span>cout&lt;&lt;endl&lt;&lt;endl&lt;&lt;"Please input the location to insert (1--11) : ";<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-spacerun: yes">     </span>cin&gt;&gt;i;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-spacerun: yes">  </span><span style="mso-spacerun: yes">   </span>cout&lt;&lt;"Please input the integer to insert (eg,58)<span style="mso-spacerun: yes">  </span>: ";<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-spacerun: yes">     </span>cin&gt;&gt;e;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-spacerun: yes">     </span>if(ListInsert_DuL(L,i,e))<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-spacerun: yes">     </span>{<span style="mso-tab-count: 1">  </span>cout &lt;&lt;endl&lt;&lt;"The new DuLNode is : ";<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span>p=L;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span>for(i=0;i&lt;INIT_LENGTH;i++)<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span>{<span style="mso-spacerun: yes">   </span><o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span><span style="mso-spacerun: yes">    </span>cout&lt;&lt;p-&gt;data&lt;&lt;" ";<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 2">       </span>p=p-&gt;next;<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-tab-count: 1">    </span>}<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-spacerun: yes">     </span>}<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-spacerun: yes">     </span>cout&lt;&lt;endl&lt;&lt;endl&lt;&lt;"...OK!...";<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'"><span style="mso-spacerun: yes">     </span>getch();<o:p></o:p></span></p><p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-FAMILY: 'Courier New'">} //main() end<o:p></o:p></span></p><img src ="http://www.cnitblog.com/chlclan/aggbug/12655.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/chlclan/" target="_blank">Enjoy Life</a> 2006-06-21 21:46 <a href="http://www.cnitblog.com/chlclan/archive/2006/06/21/12655.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>两个有序链表的合并.</title><link>http://www.cnitblog.com/chlclan/archive/2006/06/20/12584.html</link><dc:creator>Enjoy Life</dc:creator><author>Enjoy Life</author><pubDate>Tue, 20 Jun 2006 13:02:00 GMT</pubDate><guid>http://www.cnitblog.com/chlclan/archive/2006/06/20/12584.html</guid><wfw:comment>http://www.cnitblog.com/chlclan/comments/12584.html</wfw:comment><comments>http://www.cnitblog.com/chlclan/archive/2006/06/20/12584.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://www.cnitblog.com/chlclan/comments/commentRss/12584.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/chlclan/services/trackbacks/12584.html</trackback:ping><description><![CDATA[
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">void MergList_L(LNode *La, LNode *Lb, LNode *Lc){<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /?><o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">
								<span style="mso-tab-count: 1">    </span>LNode *pa, *pb, *pc;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">
								<span style="mso-tab-count: 1">    </span>pa = La-&gt;next;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">
								<span style="mso-tab-count: 1">    </span>pb = Lb-&gt;next;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">
								<span style="mso-tab-count: 1">    </span>pc = Lc = La;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">
								<span style="mso-tab-count: 1">    </span>while(pa &amp;&amp; pb){<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<font face="Courier New">
						<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
								<span style="mso-tab-count: 2">        </span>if(pa-&gt;data &lt;= pb-&gt;data){ //</span>
						<span style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">小的先挂到<span lang="EN-US">Lc</span>上去<span lang="EN-US"><o:p></o:p></span></span>
				</font>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">
								<span style="mso-tab-count: 3">            </span>pc-&gt;next = pa;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">
								<span style="mso-tab-count: 3">            </span>pc = pc-&gt;next;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">
								<span style="mso-tab-count: 3">            </span>pa = pa-&gt;next;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">
								<span style="mso-tab-count: 2">        </span>}<span style="mso-tab-count: 1">   </span><o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">
								<span style="mso-tab-count: 2">        </span>else{<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">
								<span style="mso-tab-count: 3">            </span>pc-&gt;next = pb;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">
								<span style="mso-tab-count: 3">            </span>pc-&gt;next = pc;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">
								<span style="mso-tab-count: 3">            </span>pb = pb-&gt;next;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">
								<span style="mso-tab-count: 2">        </span>}<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">
								<span style="mso-tab-count: 1">    </span>}<span style="mso-tab-count: 1">   </span><o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<font face="Courier New">
						<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
								<span style="mso-tab-count: 1">    </span>pc-&gt;next = pa? pa:pb; //</span>
						<span style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">将剩余的所有节点直接挂到<span lang="EN-US">Lc</span>上去<span lang="EN-US"><o:p></o:p></span></span>
				</font>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">
								<span style="mso-tab-count: 1">    </span>free(Lb);<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="Courier New">}<o:p></o:p></font>
				</span>
		</p>
		<p>
				<font face="Courier New">
				</font> </p>
<img src ="http://www.cnitblog.com/chlclan/aggbug/12584.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/chlclan/" target="_blank">Enjoy Life</a> 2006-06-20 21:02 <a href="http://www.cnitblog.com/chlclan/archive/2006/06/20/12584.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>两个有序顺序表的合并</title><link>http://www.cnitblog.com/chlclan/archive/2006/06/19/12523.html</link><dc:creator>Enjoy Life</dc:creator><author>Enjoy Life</author><pubDate>Mon, 19 Jun 2006 13:03:00 GMT</pubDate><guid>http://www.cnitblog.com/chlclan/archive/2006/06/19/12523.html</guid><wfw:comment>http://www.cnitblog.com/chlclan/comments/12523.html</wfw:comment><comments>http://www.cnitblog.com/chlclan/archive/2006/06/19/12523.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cnitblog.com/chlclan/comments/commentRss/12523.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/chlclan/services/trackbacks/12523.html</trackback:ping><description><![CDATA[
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: BatangChe; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">void MergList_Sq(SqList La, SqList Lb, SqList &amp;Lc){<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /?><o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: BatangChe; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 1">    </span>ElemType *pa,*pb,*pc;<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: BatangChe; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 1">    </span>int pa_length,pb_length,pc_length;<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: BatangChe; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 1">    </span>pa_length = La.length;<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: BatangChe; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 1">    </span>pb_length = Lb.length;<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: BatangChe; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 1">    </span>Lc.listsize = pa_length + pb_length;<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: BatangChe; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 1">    </span>pc = (ElemType *)malloc(listsize * sizeof(ElemType));<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: BatangChe; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 1">    </span>if(!pc){<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: BatangChe; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 2">        </span>printf("malloc was failed\n");<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: BatangChe; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 2">        </span>return;<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: BatangChe; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 1">    </span>}<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: BatangChe; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 1">    </span>Lc.elem = pc;<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: BatangChe; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 1">    </span>pa = La.elem;<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: BatangChe; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 1">    </span>pb = Lb.elem;<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: BatangChe; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 1">    </span>while(pa&lt;=&amp;La.elem[La.length-1]&amp;&amp;pb&lt;=&amp;Lb.elem[Lb.length-1]){<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: BatangChe; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 2">        </span>if(*pa&lt;=*pb)<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: BatangChe; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 3">            </span>*pc++=*pa++;<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: BatangChe; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 2">        </span>else<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: BatangChe; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 3">            </span>*pc++=*pb++;<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: BatangChe; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 1">    </span>}<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: BatangChe; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 1">    </span>while(pa&lt;=&amp;La.elem[La.length-1])<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: BatangChe; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 2">        </span>*pc++=*pa++;<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: BatangChe; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 1">    </span>while(pb&lt;=&amp;Lb.elem[Lb.length-1])<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: BatangChe; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 2">        </span>*pc++=*pb++<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: BatangChe; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">}//MergList_Sq<o:p></o:p></span>
		</p>
		<p> </p>
<img src ="http://www.cnitblog.com/chlclan/aggbug/12523.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/chlclan/" target="_blank">Enjoy Life</a> 2006-06-19 21:03 <a href="http://www.cnitblog.com/chlclan/archive/2006/06/19/12523.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>先查找Sqlist中是否有该表项,有则删除,没有...</title><link>http://www.cnitblog.com/chlclan/archive/2006/06/19/12522.html</link><dc:creator>Enjoy Life</dc:creator><author>Enjoy Life</author><pubDate>Mon, 19 Jun 2006 12:37:00 GMT</pubDate><guid>http://www.cnitblog.com/chlclan/archive/2006/06/19/12522.html</guid><wfw:comment>http://www.cnitblog.com/chlclan/comments/12522.html</wfw:comment><comments>http://www.cnitblog.com/chlclan/archive/2006/06/19/12522.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/chlclan/comments/commentRss/12522.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/chlclan/services/trackbacks/12522.html</trackback:ping><description><![CDATA[
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">//ListDelete_Sq.cpp<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /?><o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">//Delete the NO.i Element of Sq_List and get the value<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<o:p> </o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">#include &lt;stdlib.h&gt;<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">#include &lt;iostream.h&gt;<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">#include &lt;conio.h&gt;<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">#include &lt;stdio.h&gt;<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<o:p> </o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<o:p> </o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">#define ElemType int<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">#define LIST_INIT_SIZE 100<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">#define LISTINCREMENT 10<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">typedef struct <o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">{<span style="mso-tab-count: 1">   </span>int *elem;<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 1">    </span>int length;<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 1">    </span>int listsize;<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">}SqList;<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<o:p> </o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">int InitList_Sq(SqList &amp;L)<span style="mso-spacerun: yes">                                    </span>//InitList_Sq() function<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">{<span style="mso-spacerun: yes">   </span>//Inititial a Sq_List<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 1">    </span>L.elem=(int *)malloc(LIST_INIT_SIZE *sizeof(int));<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 1">    </span>if (!L.elem) return(0);<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 1">    </span>L.length=0;<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 1">    </span>L.listsize=LIST_INIT_SIZE;<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 1">    </span>return(1);<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">}//end of InitList_Sq() function<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<o:p> </o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<o:p> </o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">int ListDelete_Sq(SqList &amp;L, int i){<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 1">    </span>ElemType *p,*q;<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 1">    </span>if( i&lt;1 || i&gt;L.length){<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 2">       </span>printf("The Entry you want to Delete is not exsit\n");<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 2">       </span>return 0;<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 1">    </span>}<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 1">    </span>//e=L.elem[i-1];<span style="mso-spacerun: yes">          </span>//</span>
				<font face="宋体">
						<span style="mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">提取要删除项的内容</span>
						<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
								<o:p>
								</o:p>
						</span>
				</font>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 1">    </span>q=&amp;L.elem[L.length-1];<span style="mso-tab-count: 1">   </span>//</span>
				<font face="宋体">
						<span style="mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">最后一项的地址</span>
						<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
								<o:p>
								</o:p>
						</span>
				</font>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 1">    </span>for(p=&amp;L.elem[i];p&lt;=q;++p)<span style="mso-spacerun: yes">  </span>//</span>
				<font face="宋体">
						<span style="mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">从要删除项的后一项开始每项都往前放一个位置</span>
						<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
								<o:p>
								</o:p>
						</span>
				</font>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 2">       </span>*(p-1)=*p;<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 1">    </span>--L.length;<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 1">    </span>return 1;<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">}<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<o:p> </o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">//</span>
				<span style="mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">输入的是</font>
				</span>
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">Sqlist</span>
				<span style="mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">中的一个表项</font>
				</span>
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">,</span>
				<span style="mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">所以应该先查找再删除</font>
				</span>
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">,</span>
				<span style="mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">如果找到就删除</font>
				</span>
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">,</span>
				<font face="宋体">
						<span style="mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">没有找到返回</span>
						<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
								<o:p>
								</o:p>
						</span>
				</font>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">int LocateElem_Sq(SqList L, ElemType e){<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 1">    </span>int i;<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 1">    </span>for(i=0; i&lt;=L.length-1;i++){<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 2">       </span>if(L.elem[i] == e)<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 3">           </span>return i+1; //e</span>
				<span style="mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">的位置为第</font>
				</span>
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">i+1</span>
				<font face="宋体">
						<span style="mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">的位置</span>
						<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
								<o:p>
								</o:p>
						</span>
				</font>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 1">    </span>}<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 1">    </span>return 0; //</span>
				<font face="宋体">
						<span style="mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">没有找到</span>
						<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
								<o:p>
								</o:p>
						</span>
				</font>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">}<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<o:p> </o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">void ListDelete_Sq_bye(SqList &amp;L, ElemType e){<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 1">    </span>int i;<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 1">    </span>i=LocateElem_Sq(L,e);<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 1">    </span>if(i != 0){<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 2">       </span>printf("\n%d is one of the SqList Entry\n",e);<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 2">       </span>ListDelete_Sq(L,i);<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 1">    </span>}<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 1">    </span>else<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 2">       </span>printf("Can't found the %d\n",e);<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<o:p> </o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">}<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<o:p> </o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<o:p> </o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<o:p> </o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<o:p> </o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">void main()<span style="mso-spacerun: yes">                                             </span>//main() function<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">{<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-spacerun: yes">   </span>SqList L;<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-spacerun: yes">   </span>
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-spacerun: yes">   </span>int i,j;<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-spacerun: yes">   </span>//L.elem=array;<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-spacerun: yes">   </span>//L.length=LIST_INIT_LENGTH;<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-spacerun: yes">   </span>cout&lt;&lt;"ListDelete_Sq.cpp"&lt;&lt;endl&lt;&lt;"================="&lt;&lt;endl&lt;&lt;endl;<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-spacerun: yes">   </span>
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-spacerun: yes">   </span>InitList_Sq(L);<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-spacerun: yes">   </span>cout&lt;&lt;"Please input the Length of Demo SqList L: &lt;eg. 5&gt; ";<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-spacerun: yes">   </span>cin&gt;&gt;L.length;<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-spacerun: yes">   </span>cout&lt;&lt;"Please input the data of Demo SqList L: &lt;eg. {34,54,30,2,40,...}&gt; "&lt;&lt;endl;<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-spacerun: yes">   </span>for(j=0;j&lt;L.length;j++)<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-spacerun: yes">     </span>cin&gt;&gt;L.elem[j];<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-tab-count: 1">    </span>
						<span style="mso-spacerun: yes"> </span>
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-spacerun: yes">   </span>cout&lt;&lt;endl;<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-spacerun: yes">   </span>cout&lt;&lt;"Success to create a SqList:"&lt;&lt;endl;<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-spacerun: yes">   </span>cout&lt;&lt;"Please input the<span style="mso-spacerun: yes">  </span>element of Sq_List to delete:<span style="mso-spacerun: yes">  </span>&lt;eg. 3&gt; ";<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-spacerun: yes">   </span>cin&gt;&gt;i;<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<o:p> </o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-spacerun: yes">   </span>ListDelete_Sq_bye(L,i);<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-spacerun: yes">   </span>printf("---the data you delete is----------%d \n",i);<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-spacerun: yes">   </span>cout&lt;&lt;"The SqList After Delete is:<span style="mso-spacerun: yes">  </span>";<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-spacerun: yes">   </span>for(j=0;j&lt;L.length;j++)<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-spacerun: yes">      </span>cout&lt;&lt;L.elem[j]&lt;&lt;"<span style="mso-spacerun: yes">  </span>";<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-spacerun: yes">   </span>cout&lt;&lt;endl&lt;&lt;"...OK...!"&lt;&lt;endl;<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">
						<span style="mso-spacerun: yes">   </span>getch();<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体">}//end of main() function<o:p></o:p></span>
		</p>
<img src ="http://www.cnitblog.com/chlclan/aggbug/12522.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/chlclan/" target="_blank">Enjoy Life</a> 2006-06-19 20:37 <a href="http://www.cnitblog.com/chlclan/archive/2006/06/19/12522.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>线性表的删除(一个元素)</title><link>http://www.cnitblog.com/chlclan/archive/2006/06/19/12521.html</link><dc:creator>Enjoy Life</dc:creator><author>Enjoy Life</author><pubDate>Mon, 19 Jun 2006 12:14:00 GMT</pubDate><guid>http://www.cnitblog.com/chlclan/archive/2006/06/19/12521.html</guid><wfw:comment>http://www.cnitblog.com/chlclan/comments/12521.html</wfw:comment><comments>http://www.cnitblog.com/chlclan/archive/2006/06/19/12521.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/chlclan/comments/commentRss/12521.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/chlclan/services/trackbacks/12521.html</trackback:ping><description><![CDATA[
		<p>
				<br /> </p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">//ListDelete_Sq.cpp<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /?><o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">//Delete the NO.i Element of Sq_List and get the value<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<o:p>
								<font face="宋体"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">#include &lt;stdlib.h&gt;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">#include &lt;iostream.h&gt;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">#include &lt;conio.h&gt;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">#include &lt;stdio.h&gt;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<o:p>
								<font face="宋体"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<o:p>
								<font face="宋体"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">#define ElemType int<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">#define LIST_INIT_SIZE 100<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">#define LISTINCREMENT 10<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">typedef struct <o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">{<span style="mso-tab-count: 1">   </span>int *elem;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 1">    </span>int length;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 1">    </span>int listsize;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">}SqList;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<o:p>
								<font face="宋体"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">int InitList_Sq(SqList &amp;L)<span style="mso-spacerun: yes">                                    </span>//InitList_Sq() function<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">{<span style="mso-spacerun: yes">   </span>//Inititial a Sq_List<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 1">    </span>L.elem=(int *)malloc(LIST_INIT_SIZE *sizeof(int));<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 1">    </span>if (!L.elem) return(0);<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 1">    </span>L.length=0;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 1">    </span>L.listsize=LIST_INIT_SIZE;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 1">    </span>return(1);<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">}//end of InitList_Sq() function<br /><o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<o:p>
								<font face="宋体">
										<br />
										<br />-------------------------本函数的重点----------------------- </font>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<o:p>
								<font face="宋体"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">int ListDelete_Sq(SqList &amp;L, int i, ElemType &amp;e){<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 1">    </span>ElemType *p,*q;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 1">    </span>if( i&lt;1 || i&gt;L.length){<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 2">        </span>printf("The Entry you want to Delete is not exsit\n");<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 2">        </span>return 0;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 1">    </span>}<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<font face="宋体">
						<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
								<span style="mso-tab-count: 1">    </span>e=L.elem[i-1];<span style="mso-spacerun: yes">          </span>//</span>
						<span style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">提取要删除项的内容<span lang="EN-US"><o:p></o:p></span></span>
				</font>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<font face="宋体">
						<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
								<span style="mso-tab-count: 1">    </span>q=&amp;L.elem[L.length-1];<span style="mso-tab-count: 1">  </span>//</span>
						<span style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">最后一项的地址<span lang="EN-US"><o:p></o:p></span></span>
				</font>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<font face="宋体">
						<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
								<span style="mso-tab-count: 1">    </span>for(p=&amp;L.elem[i];p&lt;=q;++p)<span style="mso-spacerun: yes">  </span>//</span>
						<span style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">从要删除项的后一项开始每项都往前放一个位置<span lang="EN-US"><o:p></o:p></span></span>
				</font>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 2">        </span>*(p-1)=*p;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 1">    </span>--L.length;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 1">    </span>return 1;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">}<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<o:p>
								<font face="宋体"> <br /></font>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">-------------------------本函数的重点----------------------- <br />void main()<span style="mso-spacerun: yes">                                             </span>//main() function<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">{<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-spacerun: yes">   </span>SqList L;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-spacerun: yes">   </span>int e;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-spacerun: yes">   </span>int i,j;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-spacerun: yes">   </span>//L.elem=array;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-spacerun: yes">   </span>//L.length=LIST_INIT_LENGTH;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-spacerun: yes">   </span>cout&lt;&lt;"ListDelete_Sq.cpp"&lt;&lt;endl&lt;&lt;"================="&lt;&lt;endl&lt;&lt;endl;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-spacerun: yes">   </span>
								<o:p>
								</o:p>
						</font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-spacerun: yes">   </span>InitList_Sq(L);<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-spacerun: yes">   </span>cout&lt;&lt;"Please input the Length of Demo SqList L: &lt;eg. 5&gt; ";<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-spacerun: yes">   </span>cin&gt;&gt;L.length;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-spacerun: yes">   </span>cout&lt;&lt;"Please input the data of Demo SqList L: &lt;eg. {34,54,30,2,40,...}&gt; "&lt;&lt;endl;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-spacerun: yes">   </span>for(j=0;j&lt;L.length;j++)<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-spacerun: yes">     </span>cin&gt;&gt;L.elem[j];<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-tab-count: 1">    </span>
								<span style="mso-spacerun: yes"> </span>
								<o:p>
								</o:p>
						</font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-spacerun: yes">   </span>cout&lt;&lt;endl;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-spacerun: yes">   </span>cout&lt;&lt;"Success to create a SqList:"&lt;&lt;endl;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-spacerun: yes">   </span>cout&lt;&lt;"Please input the NO.i element of Sq_List to delete:<span style="mso-spacerun: yes">  </span>&lt;eg. 3&gt; ";<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-spacerun: yes">   </span>cin&gt;&gt;i;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-spacerun: yes">   </span>ListDelete_Sq(L,i,e);<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-spacerun: yes">   </span>printf("---the data you delete is----------%d \n",e);<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-spacerun: yes">   </span>cout&lt;&lt;"The SqList After Delete is:<span style="mso-spacerun: yes">  </span>";<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-spacerun: yes">   </span>for(j=0;j&lt;L.length;j++)<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-spacerun: yes">      </span>cout&lt;&lt;L.elem[j]&lt;&lt;"<span style="mso-spacerun: yes">  </span>";<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-spacerun: yes">   </span>cout&lt;&lt;endl&lt;&lt;"...OK...!"&lt;&lt;endl;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">
								<span style="mso-spacerun: yes">   </span>getch();<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">
						<font face="宋体">}//end of main() function<o:p></o:p></font>
				</span>
		</p>
		<p> </p>
<img src ="http://www.cnitblog.com/chlclan/aggbug/12521.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/chlclan/" target="_blank">Enjoy Life</a> 2006-06-19 20:14 <a href="http://www.cnitblog.com/chlclan/archive/2006/06/19/12521.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>选择排序算法代码实现</title><link>http://www.cnitblog.com/chlclan/archive/2006/06/14/12282.html</link><dc:creator>Enjoy Life</dc:creator><author>Enjoy Life</author><pubDate>Wed, 14 Jun 2006 15:50:00 GMT</pubDate><guid>http://www.cnitblog.com/chlclan/archive/2006/06/14/12282.html</guid><wfw:comment>http://www.cnitblog.com/chlclan/comments/12282.html</wfw:comment><comments>http://www.cnitblog.com/chlclan/archive/2006/06/14/12282.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/chlclan/comments/commentRss/12282.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/chlclan/services/trackbacks/12282.html</trackback:ping><description><![CDATA[
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">#include &lt;stdio.h&gt;<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /?><o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">#include &lt;stdlib.h&gt; <o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<o:p> </o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">#define MAXSIZE 20<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">#define MAX_LENGTH 100 <o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<o:p> </o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">typedef int RedType;<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">typedef struct SqList{<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-spacerun: yes"> </span>RedType r[MAXSIZE+1];<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-spacerun: yes"> </span>int length; <o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">}SqList; <o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<o:p> </o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">//</span>
				<span style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">此处用指针或者引用都可以，但是不能直接用结构来作为参数传人</span>
				<span lang="EN-US"> InsertSort(SqList &amp;L):OK<span style="mso-spacerun: yes">  </span>InsertSort(SqList L):ERROR,</span>
				<span style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">没法正常工作</span>
				<span lang="EN-US">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<o:p> </o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<o:p> </o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">/*<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">用结构来做，比较常用</span>
				<span lang="EN-US">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">void main()<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">{<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-spacerun: yes"> </span>int i;<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-spacerun: yes"> </span>SqList L;<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-spacerun: yes"> </span>printf("\nPlease input the length you want to sort\n");<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-spacerun: yes"> </span>scanf("%d",&amp;L.length);<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-spacerun: yes"> </span>for(i=1;i&lt;=L.length;i++){<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-spacerun: yes">  </span>printf("\nPlease input the %dth data\n",i);<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-spacerun: yes">  </span>scanf("%d",&amp;L.r[i]);<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-spacerun: yes"> </span>}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-spacerun: yes"> </span>printf("\nYou input data is:");<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-spacerun: yes"> </span>for(i=1;i&lt;=L.length;i++)<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-spacerun: yes">  </span>printf("%5d",L.r[i]);<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-spacerun: yes"> </span>InsertSort(&amp;L);<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-spacerun: yes"> </span>printf("\nThe sorted data is:");<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-spacerun: yes"> </span>for(i=1;i&lt;=L.length;i++)<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-spacerun: yes">  </span>printf("%5d",L.r[i]);<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-spacerun: yes"> </span>
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">*/ <o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<o:p> </o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">void SelectSort(SqList *L);<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">//</span>
				<span style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">用指针来做</span>
				<span lang="EN-US">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">void main()<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">{<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-spacerun: yes"> </span>int i;<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-spacerun: yes"> </span>SqList *L;<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-spacerun: yes"> </span>if(!(L=(SqList *)malloc(sizeof(SqList)))){<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-spacerun: yes">  </span>printf("OverFlow\n");<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-spacerun: yes">  </span>return;<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-spacerun: yes"> </span>}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-spacerun: yes"> </span>printf("\nPlease input the length you want to sort\n");<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-spacerun: yes"> </span>scanf("%d",&amp;L-&gt;length);<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-spacerun: yes"> </span>for(i=1;i&lt;=L-&gt;length;i++){<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-spacerun: yes">  </span>printf("\nPlease input the %dth data\n",i);<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-spacerun: yes">  </span>scanf("%d",&amp;L-&gt;r[i]);<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-spacerun: yes"> </span>}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-spacerun: yes"> </span>printf("\nYou input data is:");<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-spacerun: yes"> </span>for(i=1;i&lt;=L-&gt;length;i++)<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-spacerun: yes">  </span>printf("%5d",L-&gt;r[i]);<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-spacerun: yes"> </span>SelectSort(L);<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-spacerun: yes"> </span>printf("\nThe sorted data is:");<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-spacerun: yes"> </span>for(i=1;i&lt;=L-&gt;length;i++)<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-spacerun: yes">  </span>printf("%5d",L-&gt;r[i]);<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-spacerun: yes"> </span>free(L);<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-spacerun: yes"> </span>
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">} <o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<o:p> </o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<o:p> </o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<o:p> </o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<o:p> </o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">void SelectSort(SqList *L)<span style="mso-tab-count: 1">    </span>//SelectSort() sub-function<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">{<span style="mso-spacerun: yes">   </span>int i,j,k,temp;<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-spacerun: yes">    </span>for(i=1;i&lt;=L-&gt;length;++i)<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-spacerun: yes">    </span>{<span style="mso-spacerun: yes">   </span>k=i;<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>for(j=i+1;j&lt;=L-&gt;length;++j)<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>
						<span style="mso-spacerun: yes">   </span>if(L-&gt;r[j]&lt;L-&gt;r[k])<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>
						<span style="mso-spacerun: yes">       </span>k=j;<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>if(i!=k)<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>{<span style="mso-spacerun: yes">   </span>temp=L-&gt;r[i];<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>
						<span style="mso-spacerun: yes">    </span>L-&gt;r[i]=L-&gt;r[k];<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>
						<span style="mso-spacerun: yes">    </span>L-&gt;r[k]=temp;<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-spacerun: yes">    </span>}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">}//SelectSort() end</span>
		</p>
		<p> </p>
<img src ="http://www.cnitblog.com/chlclan/aggbug/12282.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/chlclan/" target="_blank">Enjoy Life</a> 2006-06-14 23:50 <a href="http://www.cnitblog.com/chlclan/archive/2006/06/14/12282.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>递归形式的快速排序算法描述</title><link>http://www.cnitblog.com/chlclan/archive/2006/06/14/12276.html</link><dc:creator>Enjoy Life</dc:creator><author>Enjoy Life</author><pubDate>Wed, 14 Jun 2006 13:48:00 GMT</pubDate><guid>http://www.cnitblog.com/chlclan/archive/2006/06/14/12276.html</guid><wfw:comment>http://www.cnitblog.com/chlclan/comments/12276.html</wfw:comment><comments>http://www.cnitblog.com/chlclan/archive/2006/06/14/12276.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/chlclan/comments/commentRss/12276.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/chlclan/services/trackbacks/12276.html</trackback:ping><description><![CDATA[void QSort(SqList &amp;L, int low, int high){<br />         <br />         if(low &lt; high){                                        //长度大于1<br />                  pivotloc = Patition(L, low, high);    //将L.r[low.....high]一分为二<br />                  QSort(L, low, pivotloc - 1);          //对低子表递归排序<br />                  QSort(L, pivotloc + 1, high);         //对高子序递归排序<br />         }<br />}//QSort<img src ="http://www.cnitblog.com/chlclan/aggbug/12276.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/chlclan/" target="_blank">Enjoy Life</a> 2006-06-14 21:48 <a href="http://www.cnitblog.com/chlclan/archive/2006/06/14/12276.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>一趟快速排序算法描述</title><link>http://www.cnitblog.com/chlclan/archive/2006/06/14/12275.html</link><dc:creator>Enjoy Life</dc:creator><author>Enjoy Life</author><pubDate>Wed, 14 Jun 2006 13:41:00 GMT</pubDate><guid>http://www.cnitblog.com/chlclan/archive/2006/06/14/12275.html</guid><wfw:comment>http://www.cnitblog.com/chlclan/comments/12275.html</wfw:comment><comments>http://www.cnitblog.com/chlclan/archive/2006/06/14/12275.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/chlclan/comments/commentRss/12275.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/chlclan/services/trackbacks/12275.html</trackback:ping><description><![CDATA[
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<font face="Courier New">
						<span style="FONT-FAMILY: 新宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">一趟快速排序算法描述：</span>
						<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体; mso-fareast-font-family: 新宋体">
								<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /?>
								<o:p>
								</o:p>
						</span>
				</font>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体; mso-fareast-font-family: 新宋体">
						<o:p> </o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体; mso-fareast-font-family: 新宋体">int Patition(SqList &amp;L, int low, int high){<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt 15.75pt; mso-para-margin-left: 1.5gd">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体; mso-fareast-font-family: 新宋体">//</span>
				<font face="Courier New">
						<span style="FONT-FAMILY: 新宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">交换顺序表</span>
						<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体; mso-fareast-font-family: 新宋体">L</span>
						<span style="FONT-FAMILY: 新宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">中子表</span>
						<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体; mso-fareast-font-family: 新宋体">L.r[low...high]</span>
						<span style="FONT-FAMILY: 新宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">的记录，使枢轴记录到位，并返回其所在位</span>
						<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体; mso-fareast-font-family: 新宋体">//</span>
						<span style="FONT-FAMILY: 新宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">置，此时它之前（后）的记录均不大（小）于它。</span>
						<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体; mso-fareast-font-family: 新宋体">
								<o:p>
								</o:p>
						</span>
				</font>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体; mso-fareast-font-family: 新宋体">
						<span style="mso-tab-count: 1">    </span>piovtkey=L.r[low].key;<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体; mso-fareast-font-family: 新宋体">
						<span style="mso-tab-count: 1">    </span>while(low&lt;high){<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体; mso-fareast-font-family: 新宋体">
						<span style="mso-tab-count: 2">       </span>while(low&lt;high &amp;&amp; L.r[high].key&gt;=piovtkey)<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体; mso-fareast-font-family: 新宋体">
						<span style="mso-tab-count: 3">           </span>--high;<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: -42pt; mso-char-indent-count: -4.0">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体; mso-fareast-font-family: 新宋体">
						<span style="mso-tab-count: 1">       </span>//</span>
				<font face="Courier New">
						<span style="FONT-FAMILY: 新宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">退出上面的循环，说明</span>
						<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体; mso-fareast-font-family: 新宋体">L.r[high].key&lt;piovtkey,</span>
						<span style="FONT-FAMILY: 新宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">从而应该和</span>
						<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体; mso-fareast-font-family: 新宋体">L.[row]</span>
						<span style="FONT-FAMILY: 新宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">交</span>
						<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体; mso-fareast-font-family: 新宋体">//</span>
						<span style="FONT-FAMILY: 新宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">换即把比枢轴记录小的记录交换到低端</span>
						<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体; mso-fareast-font-family: 新宋体">
								<o:p>
								</o:p>
						</span>
				</font>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体; mso-fareast-font-family: 新宋体">
						<span style="mso-tab-count: 2">       </span>L.r[low]&lt;----&gt;L.r[high]</span>
				<font face="Courier New">
						<span style="FONT-FAMILY: 新宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">；</span>
						<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体; mso-fareast-font-family: 新宋体">
								<o:p>
								</o:p>
						</span>
				</font>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体; mso-fareast-font-family: 新宋体">
						<span style="mso-tab-count: 2">       </span>
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体; mso-fareast-font-family: 新宋体">
						<span style="mso-tab-count: 2">       </span>while(low&lt;high &amp;&amp; L.r[low].key &lt;= piovtkey)<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体; mso-fareast-font-family: 新宋体">
						<span style="mso-tab-count: 3">           </span>++low;<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 36.75pt; mso-char-indent-count: 3.5">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体; mso-fareast-font-family: 新宋体">//</span>
				<font face="Courier New">
						<span style="FONT-FAMILY: 新宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">退出上面的循环，说明</span>
						<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体; mso-fareast-font-family: 新宋体">L.r[high].key&lt;piovtkey,</span>
						<span style="FONT-FAMILY: 新宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">从而应该和</span>
						<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体; mso-fareast-font-family: 新宋体">L.[row]</span>
						<span style="FONT-FAMILY: 新宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">交</span>
						<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体; mso-fareast-font-family: 新宋体">
								<o:p>
								</o:p>
						</span>
				</font>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 36.75pt; mso-char-indent-count: 3.5">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体; mso-fareast-font-family: 新宋体">//</span>
				<font face="Courier New">
						<span style="FONT-FAMILY: 新宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">换即把比枢轴记录小的记录交换到低端</span>
						<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体; mso-fareast-font-family: 新宋体">
								<o:p>
								</o:p>
						</span>
				</font>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体; mso-fareast-font-family: 新宋体">
						<span style="mso-tab-count: 2">       </span>L.r[row]&lt;-----&gt;L.r[high];<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体; mso-fareast-font-family: 新宋体">
						<span style="mso-tab-count: 1">    </span>}<o:p></o:p></span>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体; mso-fareast-font-family: 新宋体">
						<span style="mso-tab-count: 1">    </span>return low;//</span>
				<font face="Courier New">
						<span style="FONT-FAMILY: 新宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体">此时</span>
						<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体; mso-fareast-font-family: 新宋体">low == high<o:p></o:p></span>
				</font>
		</p>
		<p class="MsoPlainText" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 宋体; mso-fareast-font-family: 新宋体">}//Patition<o:p></o:p></span>
		</p>
<img src ="http://www.cnitblog.com/chlclan/aggbug/12275.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/chlclan/" target="_blank">Enjoy Life</a> 2006-06-14 21:41 <a href="http://www.cnitblog.com/chlclan/archive/2006/06/14/12275.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>折半插入查找代码实现</title><link>http://www.cnitblog.com/chlclan/archive/2006/06/14/12220.html</link><dc:creator>Enjoy Life</dc:creator><author>Enjoy Life</author><pubDate>Wed, 14 Jun 2006 01:49:00 GMT</pubDate><guid>http://www.cnitblog.com/chlclan/archive/2006/06/14/12220.html</guid><wfw:comment>http://www.cnitblog.com/chlclan/comments/12220.html</wfw:comment><comments>http://www.cnitblog.com/chlclan/archive/2006/06/14/12220.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/chlclan/comments/commentRss/12220.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/chlclan/services/trackbacks/12220.html</trackback:ping><description><![CDATA[
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">#include &lt;stdio.h&gt;<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /?><o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">#include &lt;stdlib.h&gt;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<o:p>
								<font face="Courier New"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">#define MAXSIZE 20<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">#define MAX_LENGTH 100<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<o:p>
								<font face="Courier New"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">typedef int RedType;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">typedef struct SqList{<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 1">       </span>RedType r[MAXSIZE+1];<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 1">       </span>int length;<span style="mso-tab-count: 1">       </span><o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">}SqList;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<o:p>
								<font face="Courier New"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<font face="Courier New">
						<span lang="EN-US">//</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">此处用指针或者引用都可以，但是不能直接用结构来作为参数传人</span>
						<span lang="EN-US"> InsertSort(SqList &amp;L):OK<span style="mso-spacerun: yes">  </span>InsertSort(SqList L):ERROR,</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">没法正常工作</span>
						<span lang="EN-US">
								<o:p>
								</o:p>
						</span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">void BiInsertSort(SqList *L)<span style="mso-tab-count: 1">  </span><o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">{<span style="mso-spacerun: yes">  </span>int i,j,low,high,mid;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-spacerun: yes">   </span>for(i=2;i&lt;=L-&gt;length;++i)<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-spacerun: yes">       </span>if(L-&gt;r[i]&lt;L-&gt;r[i-1]){<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 3">                     </span>L-&gt;r[0] = L-&gt;r[i];<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 3">                     </span>high=i-1;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 3">                     </span>low=1;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 3">                     </span>while(low&lt;=high){<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 4">                            </span>mid=(low+high)/2;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 4">                            </span>if(L-&gt;r[0]&lt;L-&gt;r[mid])<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 5">                                   </span>high=mid-1;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 4">                            </span>else<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 5">                                   </span>low=mid+1;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 3">                     </span>}<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 3">                     </span>for(j=i-1;j&gt;=high+1;--j)<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 4">                            </span>L-&gt;r[j+1]=L-&gt;r[j];<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 3">                     </span>L-&gt;r[high+1]=L-&gt;r[0];<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 1">       </span>
								<span style="mso-spacerun: yes">   </span>}<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<o:p>
								<font face="Courier New"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">}<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<o:p>
								<font face="Courier New"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<o:p>
								<font face="Courier New"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<o:p>
								<font face="Courier New"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">/*<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<font face="Courier New">
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">用结构来做，比较常用</span>
						<span lang="EN-US">
								<o:p>
								</o:p>
						</span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">void main()<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">{<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 1">       </span>int i;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 1">       </span>SqList L;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 1">       </span>printf("\nPlease input the length you want to sort\n");<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 1">       </span>scanf("%d",&amp;L.length);<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 1">       </span>for(i=1;i&lt;=L.length;i++){<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 2">              </span>printf("\nPlease input the %dth data\n",i);<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 2">              </span>scanf("%d",&amp;L.r[i]);<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 1">       </span>}<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 1">       </span>printf("\nYou input data is:");<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 1">       </span>for(i=1;i&lt;=L.length;i++)<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 2">              </span>printf("%5d",L.r[i]);<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 1">       </span>BiInsertSort(&amp;L);<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 1">       </span>printf("\nThe sorted data is:");<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 1">       </span>for(i=1;i&lt;=L.length;i++)<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 2">              </span>printf("%5d",L.r[i]);<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 1">       </span>
								<o:p>
								</o:p>
						</font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">}<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">*/<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<o:p>
								<font face="Courier New"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<font face="Courier New">
						<span lang="EN-US">//</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">用指针来做</span>
						<span lang="EN-US">
								<o:p>
								</o:p>
						</span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">void main()<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">{<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 1">       </span>int i;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 1">       </span>SqList *L;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 1">       </span>if(!(L=(SqList *)malloc(sizeof(SqList)))){<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 2">              </span>printf("OverFlow\n");<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 2">              </span>return;<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 1">       </span>}<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 1">       </span>printf("\nPlease input the length you want to sort\n");<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 1">       </span>scanf("%d",&amp;L-&gt;length);<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 1">       </span>for(i=1;i&lt;=L-&gt;length;i++){<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 2">              </span>printf("\nPlease input the %dth data\n",i);<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 2">              </span>scanf("%d",&amp;L-&gt;r[i]);<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 1">       </span>}<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 1">       </span>printf("\nYou input data is:");<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 1">       </span>for(i=1;i&lt;=L-&gt;length;i++)<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 2">              </span>printf("%5d",L-&gt;r[i]);<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 1">       </span>BiInsertSort(L);<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 1">       </span>printf("\nThe sorted data is:");<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 1">       </span>for(i=1;i&lt;=L-&gt;length;i++)<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 2">              </span>printf("%5d",L-&gt;r[i]);<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 1">       </span>free(L);<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">
								<span style="mso-tab-count: 1">       </span>
								<o:p>
								</o:p>
						</font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Courier New">}</font>
				</span>
		</p>
<img src ="http://www.cnitblog.com/chlclan/aggbug/12220.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/chlclan/" target="_blank">Enjoy Life</a> 2006-06-14 09:49 <a href="http://www.cnitblog.com/chlclan/archive/2006/06/14/12220.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>插入排序工作代码</title><link>http://www.cnitblog.com/chlclan/archive/2006/06/14/12214.html</link><dc:creator>Enjoy Life</dc:creator><author>Enjoy Life</author><pubDate>Wed, 14 Jun 2006 01:23:00 GMT</pubDate><guid>http://www.cnitblog.com/chlclan/archive/2006/06/14/12214.html</guid><wfw:comment>http://www.cnitblog.com/chlclan/comments/12214.html</wfw:comment><comments>http://www.cnitblog.com/chlclan/archive/2006/06/14/12214.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/chlclan/comments/commentRss/12214.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/chlclan/services/trackbacks/12214.html</trackback:ping><description><![CDATA[
		<p>
				<font face="Courier New">#include &lt;stdio.h&gt;<br />#include &lt;stdlib.h&gt;</font>
		</p>
		<p>
				<font face="Courier New">#define MAXSIZE 20<br />#define MAX_LENGTH 100</font>
		</p>
		<p>
				<font face="Courier New">typedef int RedType;<br />typedef struct SqList{<br /> RedType r[MAXSIZE+1];<br /> int length; <br />}SqList;</font>
		</p>
		<p>
				<font face="Courier New">//此处用指针或者引用都可以，但是不能直接用结构来作为参数传人 InsertSort(SqList &amp;L):OK  InsertSort(SqList L):ERROR,没法正常工作<br />void InsertSort(SqList *L) <br />{  int i,j;<br />   for(i=2;i&lt;=L-&gt;length;++i)<br />       if(L-&gt;r[i]&lt;L-&gt;r[i-1])<br />       {  L-&gt;r[0]=L-&gt;r[i];<br />   for(j=i-1;L-&gt;r[0]&lt;L-&gt;r[j];--j)<br />      L-&gt;r[j+1]=L-&gt;r[j];<br />   L-&gt;r[j+1]=L-&gt;r[0];<br />       }<br />}</font>
		</p>
		<p>
				<font face="Courier New">/*<br />用结构来做，比较常用<br />void main()<br />{<br /> int i;<br /> SqList L;<br /> printf("\nPlease input the length you want to sort\n");<br /> scanf("%d",&amp;L.length);<br /> for(i=1;i&lt;=L.length;i++){<br />  printf("\nPlease input the %dth data\n",i);<br />  scanf("%d",&amp;L.r[i]);<br /> }<br /> printf("\nYou input data is:");<br /> for(i=1;i&lt;=L.length;i++)<br />  printf("%5d",L.r[i]);<br /> InsertSort(&amp;L);<br /> printf("\nThe sorted data is:");<br /> for(i=1;i&lt;=L.length;i++)<br />  printf("%5d",L.r[i]);<br /> <br />}<br />*/</font>
		</p>
		<p>
				<font face="Courier New">//用指针来做<br />void main()<br />{<br /> int i;<br /> SqList *L;<br /> if(!(L=(SqList *)malloc(sizeof(SqList)))){<br />  printf("OverFlow\n");<br />  return;<br /> }<br /> printf("\nPlease input the length you want to sort\n");<br /> scanf("%d",&amp;L-&gt;length);<br /> for(i=1;i&lt;=L-&gt;length;i++){<br />  printf("\nPlease input the %dth data\n",i);<br />  scanf("%d",&amp;L-&gt;r[i]);<br /> }<br /> printf("\nYou input data is:");<br /> for(i=1;i&lt;=L-&gt;length;i++)<br />  printf("%5d",L-&gt;r[i]);<br /> InsertSort(L);<br /> printf("\nThe sorted data is:");<br /> for(i=1;i&lt;=L-&gt;length;i++)<br />  printf("%5d",L-&gt;r[i]);<br /> free(L);<br /> <br />}</font>
		</p>
<img src ="http://www.cnitblog.com/chlclan/aggbug/12214.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/chlclan/" target="_blank">Enjoy Life</a> 2006-06-14 09:23 <a href="http://www.cnitblog.com/chlclan/archive/2006/06/14/12214.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>冒泡排序算法描述</title><link>http://www.cnitblog.com/chlclan/archive/2006/06/13/12201.html</link><dc:creator>Enjoy Life</dc:creator><author>Enjoy Life</author><pubDate>Tue, 13 Jun 2006 14:53:00 GMT</pubDate><guid>http://www.cnitblog.com/chlclan/archive/2006/06/13/12201.html</guid><wfw:comment>http://www.cnitblog.com/chlclan/comments/12201.html</wfw:comment><comments>http://www.cnitblog.com/chlclan/archive/2006/06/13/12201.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cnitblog.com/chlclan/comments/commentRss/12201.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/chlclan/services/trackbacks/12201.html</trackback:ping><description><![CDATA[
		<p>冒泡排序法：</p>
		<p>void BubbleSort(Elem R[], int n){<br /> i=n;<br /> while(i&gt;1){<br />  LastExchange = 1;<br />  for(j=1; j&lt;i; j++){<br />   if(R[j+1]&lt;R[j]){<br />    Swap(R[j],R[j+1]);<br />    LastExchange=j;<br />   }<br />  }<br />  i=LastExchange;<br /> <br /> }//while<br />}//BubbleSort<br />起泡排序的结束条件是：最后一趟没有进行“交换”</p>
<img src ="http://www.cnitblog.com/chlclan/aggbug/12201.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/chlclan/" target="_blank">Enjoy Life</a> 2006-06-13 22:53 <a href="http://www.cnitblog.com/chlclan/archive/2006/06/13/12201.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>希尔排序算法描述</title><link>http://www.cnitblog.com/chlclan/archive/2006/06/13/12198.html</link><dc:creator>Enjoy Life</dc:creator><author>Enjoy Life</author><pubDate>Tue, 13 Jun 2006 14:26:00 GMT</pubDate><guid>http://www.cnitblog.com/chlclan/archive/2006/06/13/12198.html</guid><wfw:comment>http://www.cnitblog.com/chlclan/comments/12198.html</wfw:comment><comments>http://www.cnitblog.com/chlclan/archive/2006/06/13/12198.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/chlclan/comments/commentRss/12198.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/chlclan/services/trackbacks/12198.html</trackback:ping><description><![CDATA[
		<p>
				<font face="Courier New">void ShellInsert(SqList &amp;L, int dk){<br /> //对顺序表L作一趟希尔插入排序，本算法是和一趟直接插入排序相比，做了以下修改：<br /> // 1、前后记录位置的增量是dk，而不是1；<br /> // 2、r[0]只是暂存单元，不是哨兵。当j&lt;=0时，插入位置已找到<br /> <br /> for(i=dk+1; i&lt;=L.length; ++1){<br />  if(LT(L.r[i].key, L.r[i-dk].key)){//需将L.r[i]插入有序增量子表中<br />   L.r[0] = L.r[i];   //暂存在L.r[0]<br />   for(j=i-dk; j&gt;0 &amp;&amp; LT(L.r[0].key, L.[j].key); j-=dk)<br />    L.r[j+dk] = L.r[j];//记录后移，查找插入位置<br />   L.r[j+dk] = L.r[0];//插入<br />  }<br /> }<br />}//ShellInsert</font>
		</p>
		<p>
				<font face="Courier New">
				</font> </p>
		<p>
				<font face="Courier New">void ShellSort(SqList &amp;L, int dlta[], int t){<br /> //增量序列dlta[0...t-1]对顺序表L作希尔排序<br /> for(k=0;k&lt;t;++k)<br />  ShellInsert(L,dlta[k]);<br />}//ShellSort</font>
		</p>
<img src ="http://www.cnitblog.com/chlclan/aggbug/12198.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/chlclan/" target="_blank">Enjoy Life</a> 2006-06-13 22:26 <a href="http://www.cnitblog.com/chlclan/archive/2006/06/13/12198.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>折半插入排序</title><link>http://www.cnitblog.com/chlclan/archive/2006/06/13/12194.html</link><dc:creator>Enjoy Life</dc:creator><author>Enjoy Life</author><pubDate>Tue, 13 Jun 2006 13:46:00 GMT</pubDate><guid>http://www.cnitblog.com/chlclan/archive/2006/06/13/12194.html</guid><wfw:comment>http://www.cnitblog.com/chlclan/comments/12194.html</wfw:comment><comments>http://www.cnitblog.com/chlclan/archive/2006/06/13/12194.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.cnitblog.com/chlclan/comments/commentRss/12194.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/chlclan/services/trackbacks/12194.html</trackback:ping><description><![CDATA[
		<p>
				<font face="Courier New">void BiInsertionSort(SqList &amp;L){<br />  <font size="2"> //对顺序表L作折半插入排序<br /></font>   for(i=2; i&lt;=L.length; ++i){<br />      L.r[0] = L.r[i];<br />      low = 1;<br />      high = i-1;<br /><br /><font size="2">        //查找i记录应该插入的位置，必定是high+1的位置从而high+1位置以后的元素都应该往后移动一个位置，留出一个位置放入L.r[i]</font><br />      while(low &lt;= high){<br />         mid = (low + high)/2;<br />         if(LT(L.r[0], L.r[m].key))<br />            high = m - 1;<br />         else<br />            low = m + 1;<br />      }<br />     <font size="2"> //后移</font><br />      for(j=i-1; j&gt;=high+1; --j)<br />         L.r[j+1] = L.r[j];<br />      <font size="2">//插入元素</font><br />      L.r[high+1] = L.r[0];<br />   }<br />}</font>
		</p>
<img src ="http://www.cnitblog.com/chlclan/aggbug/12194.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/chlclan/" target="_blank">Enjoy Life</a> 2006-06-13 21:46 <a href="http://www.cnitblog.com/chlclan/archive/2006/06/13/12194.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>插入排序算法描述</title><link>http://www.cnitblog.com/chlclan/archive/2006/06/13/12192.html</link><dc:creator>Enjoy Life</dc:creator><author>Enjoy Life</author><pubDate>Tue, 13 Jun 2006 13:17:00 GMT</pubDate><guid>http://www.cnitblog.com/chlclan/archive/2006/06/13/12192.html</guid><wfw:comment>http://www.cnitblog.com/chlclan/comments/12192.html</wfw:comment><comments>http://www.cnitblog.com/chlclan/archive/2006/06/13/12192.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/chlclan/comments/commentRss/12192.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/chlclan/services/trackbacks/12192.html</trackback:ping><description><![CDATA[
		<font face="Courier New" size="2">void InsertionSort(Elem R[], int n){<br />  //对记录序列R[1...n]做直接插入排序<br />   for(i=2; i&lt;=n; ++i){//<font size="1">一个数肯定是有序的<br /><br />        //后一个数比前一个数小才需要进行插入，否则不用移动数字就可以<br /></font>      if(R[i].key &lt; R[i-1].key){<font size="1"><br /></font>         R[0] = R[i]; <font size="1">//哨兵<br /></font>         <br />      <font size="1">   //找到R[i]该插入的位置，同时把R[i]大的数字都往后移一位，留出一个位置用于放R[i],该循环完成之后，位置找到，并且，后移也随之完成</font><br />         for(j=i-1; R[0].key&lt;R[j].key; --j)<br />            R[j+1]=R[j];<br />         <font size="1">//再空的位置放上R[0]</font><br />         R[j+1]=R[0];<br />      }<br />      <br />   }<br />}</font>
<img src ="http://www.cnitblog.com/chlclan/aggbug/12192.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/chlclan/" target="_blank">Enjoy Life</a> 2006-06-13 21:17 <a href="http://www.cnitblog.com/chlclan/archive/2006/06/13/12192.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>折半查找</title><link>http://www.cnitblog.com/chlclan/archive/2006/06/13/12167.html</link><dc:creator>Enjoy Life</dc:creator><author>Enjoy Life</author><pubDate>Tue, 13 Jun 2006 06:16:00 GMT</pubDate><guid>http://www.cnitblog.com/chlclan/archive/2006/06/13/12167.html</guid><wfw:comment>http://www.cnitblog.com/chlclan/comments/12167.html</wfw:comment><comments>http://www.cnitblog.com/chlclan/archive/2006/06/13/12167.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/chlclan/comments/commentRss/12167.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/chlclan/services/trackbacks/12167.html</trackback:ping><description><![CDATA[
		<p>
				<br />#include &lt;stdio.h&gt;<br />#include &lt;stdlib.h&gt;</p>
		<p>#define MAX_LENGTH 100<br />typedef int KeyType;</p>
		<p>typedef struct {<br /> KeyType *elem;<br /> int length; <br />}SSTable; //顺序表的存储结构</p>
		<p>#define EQ(a, b) ((a) == (b))<br />#define LT(a, b) ((a) &lt; (b))<br />#define LQ(a, b) ((a) &lt;= (b)) </p>
		<p>
				<br />int Search_Seq(SSTable ST, KeyType key){<br /> int mid,low,high;<br /> low = 1;<br /> high = ST.length;<br /> <br /> <br /> while(low &lt;= high){<br />  mid = (low + high)/2;<br />  if(EQ(key, ST.elem[mid]))<br />   return mid;  //找到数据所在的位置<br />  else if(LT(key, ST.elem[mid]))<br />   high = mid - 1;<br />  else <br />   low = mid + 1; <br /> }<br /> return 0; //没有找到数据<br />}</p>
		<p>
				<br />void main()<br />{<br /> int i, key;<br /> SSTable T;<br /> T.elem = (KeyType *)malloc(sizeof(KeyType));<br /> printf("How Many Entries Do You Want input\n");<br /> scanf("%d", &amp;T.length);<br /> for(i=1; i&lt;=T.length; i++){<br />  printf("Please input the %dth entries \n", i);<br />  scanf("%d", &amp;T.elem[i]);<br /> }<br /> for (i=1; i&lt;=T.length; i++)<br />  printf("%5d",T.elem[i]); //显示已经输入的所有数据<br /> printf("\nPlease input the data you want to search\n");<br /> scanf("%d", &amp;key);<br /> i = Search_Seq(T,key);<br /> printf("the search data is locate the %dth(0 indicate can not find)\n",i); <br />}</p>
<img src ="http://www.cnitblog.com/chlclan/aggbug/12167.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/chlclan/" target="_blank">Enjoy Life</a> 2006-06-13 14:16 <a href="http://www.cnitblog.com/chlclan/archive/2006/06/13/12167.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>顺序查找算法</title><link>http://www.cnitblog.com/chlclan/archive/2006/06/13/12166.html</link><dc:creator>Enjoy Life</dc:creator><author>Enjoy Life</author><pubDate>Tue, 13 Jun 2006 06:15:00 GMT</pubDate><guid>http://www.cnitblog.com/chlclan/archive/2006/06/13/12166.html</guid><wfw:comment>http://www.cnitblog.com/chlclan/comments/12166.html</wfw:comment><comments>http://www.cnitblog.com/chlclan/archive/2006/06/13/12166.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/chlclan/comments/commentRss/12166.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/chlclan/services/trackbacks/12166.html</trackback:ping><description><![CDATA[
		<p>
				<br />#include &lt;stdio.h&gt;<br />#include &lt;stdlib.h&gt;</p>
		<p>#define MAX_LENGTH 100<br />typedef int KeyType;</p>
		<p>typedef struct {<br /> KeyType *elem;<br /> int length; <br />}SSTable; //顺序表的存储结构</p>
		<p>
				<br />/*<br />此算法比第二个算法多了一个判定i是否出界的流程，对于查找数目较少的情况，<br />二者查找时间相差不大，对于存在大量数据时，该算法的主要查找时间消耗再判<br />定是否出界上，所以第二个算法明显比第一个算法好，唯一增加的就是一个“哨兵”<br />数据。<br />int Search_Seq(SSTable ST, KeyType key){<br /> int i;<br /> for(i=1; i&lt;=ST.length &amp;&amp; ST.elem[i] != key; i++ )<br />  ;<br /> if(i&lt;=ST.length)<br />  return i;<br /> else<br />  return 0;<br />}<br />*/</p>
		<p>int Search_Seq(SSTable ST, KeyType key){<br /> int i;<br /> ST.elem[0] = key; //“哨兵”，如果顺序表中不存在要查找的数据的话，则查找指针必定指向该哨兵<br /> for(i = ST.length; ST.elem[i] != key; i--)<br />  ;<br /> return i;  //找到的话，则i != 0,否则i = 0<br />}</p>
		<p>
				<br />void main()<br />{<br /> int i, key;<br /> SSTable T;<br /> T.elem = (KeyType *)malloc(sizeof(KeyType));<br /> printf("How Many Entries Do You Want input\n");<br /> scanf("%d", &amp;T.length);<br /> for(i=1; i&lt;=T.length; i++){<br />  printf("Please input the %dth entries \n", i);<br />  scanf("%d", &amp;T.elem[i]);<br /> }<br /> for (i=1; i&lt;=T.length; i++)<br />  printf("%5d",T.elem[i]); //显示已经输入的所有数据<br /> printf("\nPlease input the data you want to search\n");<br /> scanf("%d", &amp;key);<br /> i = Search_Seq(T,key);<br /> printf("the search data is locate the %dth(0 indicate can not find)\n",i); <br />}</p>
<img src ="http://www.cnitblog.com/chlclan/aggbug/12166.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/chlclan/" target="_blank">Enjoy Life</a> 2006-06-13 14:15 <a href="http://www.cnitblog.com/chlclan/archive/2006/06/13/12166.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>二叉树的遍历</title><link>http://www.cnitblog.com/chlclan/archive/2006/06/08/11861.html</link><dc:creator>Enjoy Life</dc:creator><author>Enjoy Life</author><pubDate>Thu, 08 Jun 2006 13:57:00 GMT</pubDate><guid>http://www.cnitblog.com/chlclan/archive/2006/06/08/11861.html</guid><wfw:comment>http://www.cnitblog.com/chlclan/comments/11861.html</wfw:comment><comments>http://www.cnitblog.com/chlclan/archive/2006/06/08/11861.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/chlclan/comments/commentRss/11861.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/chlclan/services/trackbacks/11861.html</trackback:ping><description><![CDATA[
		<p>树的遍历：实际访问树中各个节点时，需要路过节点三次，如果如果第一次访问该节点就对其实施Visit函数的话，称为先序遍历，第二访问时实施Visit函数，则为中序遍历，最后访问时实施则为后序遍历。<br /><br /><br /><br />#include &lt;stdio.h&gt;<br />#include &lt;stdlib.h&gt;</p>
		<p>typedef int    TElemType;<br />//typedef 1 OK;<br />//typedef 0 ERROR;</p>
		<p>#define OK 1;<br />#define ERROR 0;</p>
		<p>typedef struct BiTNode {<br /> TElemType data;<br /> struct BiTNode  *lchild, *rchild;<br />}BiTNode;</p>
		<p>int PrintElem(TElemType e){<br /> printf("Node Elem is %d", e);<br /> return OK; <br />}</p>
		<p>
				<br />int PreOderTraverse(BiTNode *tree, int(* PrintElem)(TElemType e)){<br /> if(tree){<br />  if(PrintElem(tree-&gt;data))<br />   if(PreOderTraverse(tree-&gt;lchild, PrintElem))<br />    if(PreOderTraverse(tree-&gt;rchild,PrintElem))<br />     return OK;<br />  return ERROR;<br />       <br /> }<br /> else<br />  return OK;<br />}</p>
		<p>
				<br />//Create New Tree;</p>
		<p>int CreateBiTree(BiTNode *tree){<br /> BiTNode *T;<br /> printf("please input int data to create bitree, enter 0 for finishing\n");<br /> TElemType i;<br /> scanf("%d",&amp;i);<br /> if (i == 0){<br />  T = NULL;<br />  printf("Tree is NULL \n ");<br />  return ERROR;<br /> }<br /> else {<br />  if(!(T = (BiTNode *)malloc(sizeof(BiTNode)))){<br />   printf("OverFlow\n");<br />   return ERROR;<br />  }<br />  T-&gt;data = i;<br />  CreateBiTree(T-&gt;lchild);<br />  CreateBiTree(T-&gt;rchild);<br />  <br /> }//else end<br />}</p>
		<p>
				<br />void main()<br />{ <br /> BiTNode *Tree;<br /> printf("input data to create a new BiTree \n");<br /> CreateBiTree(Tree);<br /> PreOderTraverse(Tree,PrintElem);<br /> return ;<br />}</p>
		<p>
				<br /> </p>
<img src ="http://www.cnitblog.com/chlclan/aggbug/11861.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/chlclan/" target="_blank">Enjoy Life</a> 2006-06-08 21:57 <a href="http://www.cnitblog.com/chlclan/archive/2006/06/08/11861.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>