﻿<?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>Fri, 09 Mar 2007 13:42:52 GMT</lastBuildDate><pubDate>Fri, 09 Mar 2007 13:42:52 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>0</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>0</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="ms