﻿<?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>C++博客-C++ Jounior-随笔分类-算法＋数据结构</title><link>http://www.cppblog.com/snowball/category/6581.html</link><description>once setback,once inspiration,once self-awareness&lt;br&gt;
重要的是这个磨练过程，而不是结果，要的是你粗壮的腿，而不是你身上背的那袋盐巴</description><language>zh-cn</language><lastBuildDate>Mon, 07 Jul 2008 02:51:25 GMT</lastBuildDate><pubDate>Mon, 07 Jul 2008 02:51:25 GMT</pubDate><ttl>60</ttl><item><title> 银行家算法</title><link>http://www.cppblog.com/snowball/archive/2008/07/06/55485.html</link><dc:creator>snowball</dc:creator><author>snowball</author><pubDate>Sun, 06 Jul 2008 14:16:00 GMT</pubDate><guid>http://www.cppblog.com/snowball/archive/2008/07/06/55485.html</guid><wfw:comment>http://www.cppblog.com/snowball/comments/55485.html</wfw:comment><comments>http://www.cppblog.com/snowball/archive/2008/07/06/55485.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/snowball/comments/commentRss/55485.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/snowball/services/trackbacks/55485.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: reference ; http://www.yuanma.org/data/2008/0116/article_2945.htm算法的实现 一、初始化		由用户输入数据，分别对可利用资源向量矩阵AVAILABLE、最大需求矩阵MAX、分配矩阵ALLOCATION、需求矩阵NEED赋值。		 		二、银行家算法		在避免死锁的方法中，所施加的限制条件较弱，有可能获得令人满意的系统性...&nbsp;&nbsp;<a href='http://www.cppblog.com/snowball/archive/2008/07/06/55485.html'>阅读全文</a><img src ="http://www.cppblog.com/snowball/aggbug/55485.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/snowball/" target="_blank">snowball</a> 2008-07-06 22:16 <a href="http://www.cppblog.com/snowball/archive/2008/07/06/55485.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>求得含有最多连续特定字符个数的字符串</title><link>http://www.cppblog.com/snowball/archive/2008/04/02/45996.html</link><dc:creator>snowball</dc:creator><author>snowball</author><pubDate>Wed, 02 Apr 2008 01:30:00 GMT</pubDate><guid>http://www.cppblog.com/snowball/archive/2008/04/02/45996.html</guid><wfw:comment>http://www.cppblog.com/snowball/comments/45996.html</wfw:comment><comments>http://www.cppblog.com/snowball/archive/2008/04/02/45996.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/snowball/comments/commentRss/45996.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/snowball/services/trackbacks/45996.html</trackback:ping><description><![CDATA[
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> GetMaxCountofContinuousLetter(</span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000"> p,</span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> searchChar)<br /><img id="Codehighlighter1_60_366_Open_Image" onclick="this.style.display='none'; Codehighlighter1_60_366_Open_Text.style.display='none'; Codehighlighter1_60_366_Closed_Image.style.display='inline'; Codehighlighter1_60_366_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_60_366_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_60_366_Closed_Text.style.display='none'; Codehighlighter1_60_366_Open_Image.style.display='inline'; Codehighlighter1_60_366_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_60_366_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
						<img src="http://www.cppblog.com/images/dot.gif" />
				</span>
				<span id="Codehighlighter1_60_366_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> maxCount </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> currentCount </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">while</span>
						<span style="COLOR: #000000">(</span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_114_346_Open_Image" onclick="this.style.display='none'; Codehighlighter1_114_346_Open_Text.style.display='none'; Codehighlighter1_114_346_Closed_Image.style.display='inline'; Codehighlighter1_114_346_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_114_346_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_114_346_Closed_Text.style.display='none'; Codehighlighter1_114_346_Open_Image.style.display='inline'; Codehighlighter1_114_346_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_114_346_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.cppblog.com/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_114_346_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">if</span>
								<span style="COLOR: #000000">(</span>
								<span style="COLOR: #000000">*</span>
								<span style="COLOR: #000000">p </span>
								<span style="COLOR: #000000">==</span>
								<span style="COLOR: #000000"> searchChar)<br /><img id="Codehighlighter1_141_299_Open_Image" onclick="this.style.display='none'; Codehighlighter1_141_299_Open_Text.style.display='none'; Codehighlighter1_141_299_Closed_Image.style.display='inline'; Codehighlighter1_141_299_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_141_299_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_141_299_Closed_Text.style.display='none'; Codehighlighter1_141_299_Open_Image.style.display='inline'; Codehighlighter1_141_299_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
								<span id="Codehighlighter1_141_299_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
										<img src="http://www.cppblog.com/images/dot.gif" />
								</span>
								<span id="Codehighlighter1_141_299_Open_Text">
										<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            currentCount </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #000000">0</span>
										<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #0000ff">while</span>
										<span style="COLOR: #000000">(</span>
										<span style="COLOR: #000000">*</span>
										<span style="COLOR: #000000">p </span>
										<span style="COLOR: #000000">&amp;&amp;</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #000000">*</span>
										<span style="COLOR: #000000">p </span>
										<span style="COLOR: #000000">==</span>
										<span style="COLOR: #000000"> searchChar)<br /><img id="Codehighlighter1_200_235_Open_Image" onclick="this.style.display='none'; Codehighlighter1_200_235_Open_Text.style.display='none'; Codehighlighter1_200_235_Closed_Image.style.display='inline'; Codehighlighter1_200_235_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_200_235_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_200_235_Closed_Text.style.display='none'; Codehighlighter1_200_235_Open_Image.style.display='inline'; Codehighlighter1_200_235_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />            </span>
										<span id="Codehighlighter1_200_235_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
												<img src="http://www.cppblog.com/images/dot.gif" />
										</span>
										<span id="Codehighlighter1_200_235_Open_Text">
												<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                currentCount </span>
												<span style="COLOR: #000000">++</span>
												<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                p</span>
												<span style="COLOR: #000000">++</span>
												<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />            }</span>
										</span>
										<span style="COLOR: #000000">
												<br />
												<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #0000ff">if</span>
										<span style="COLOR: #000000">(maxCount </span>
										<span style="COLOR: #000000">&lt;</span>
										<span style="COLOR: #000000"> currentCount)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                maxCount </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> currentCount;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
										<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">if</span>
								<span style="COLOR: #000000">(</span>
								<span style="COLOR: #000000">*</span>
								<span style="COLOR: #000000">p </span>
								<span style="COLOR: #000000">==</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">'</span>
								<span style="COLOR: #000000">\0</span>
								<span style="COLOR: #000000">'</span>
								<span style="COLOR: #000000">) <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
								<span style="COLOR: #0000ff">break</span>
								<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">else</span>
								<span style="COLOR: #000000">
										<br />
										<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            p</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">return</span>
						<span style="COLOR: #000000"> maxCount;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> main()     <br /><img id="Codehighlighter1_384_978_Open_Image" onclick="this.style.display='none'; Codehighlighter1_384_978_Open_Text.style.display='none'; Codehighlighter1_384_978_Closed_Image.style.display='inline'; Codehighlighter1_384_978_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_384_978_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_384_978_Closed_Text.style.display='none'; Codehighlighter1_384_978_Open_Image.style.display='inline'; Codehighlighter1_384_978_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_384_978_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
						<img src="http://www.cppblog.com/images/dot.gif" />
				</span>
				<span id="Codehighlighter1_384_978_Open_Text">
						<span style="COLOR: #000000">{  <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">char</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">*</span>
						<span style="COLOR: #000000">p[</span>
						<span style="COLOR: #000000">3</span>
						<span style="COLOR: #000000">]</span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000">
								<br />
								<img id="Codehighlighter1_402_565_Open_Image" onclick="this.style.display='none'; Codehighlighter1_402_565_Open_Text.style.display='none'; Codehighlighter1_402_565_Closed_Image.style.display='inline'; Codehighlighter1_402_565_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
								<img id="Codehighlighter1_402_565_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_402_565_Closed_Text.style.display='none'; Codehighlighter1_402_565_Open_Image.style.display='inline'; Codehighlighter1_402_565_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_402_565_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.cppblog.com/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_402_565_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">String(1)8818882348888856788888888988888888880</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">,<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">String(2)881888234888885678888888898888888880</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">,<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">String(3)8818882348888856788888888988888888888888880</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">
										<br />
										<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> location </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">char</span>
						<span style="COLOR: #000000"> searchChar </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">8</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> tempCount </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> maxCount </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">for</span>
						<span style="COLOR: #000000">(</span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> i </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">;i</span>
						<span style="COLOR: #000000">&lt;</span>
						<span style="COLOR: #0000ff">sizeof</span>
						<span style="COLOR: #000000">(p)</span>
						<span style="COLOR: #000000">/</span>
						<span style="COLOR: #0000ff">sizeof</span>
						<span style="COLOR: #000000">(</span>
						<span style="COLOR: #000000">*</span>
						<span style="COLOR: #000000">p);i</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_694_837_Open_Image" onclick="this.style.display='none'; Codehighlighter1_694_837_Open_Text.style.display='none'; Codehighlighter1_694_837_Closed_Image.style.display='inline'; Codehighlighter1_694_837_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_694_837_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_694_837_Closed_Text.style.display='none'; Codehighlighter1_694_837_Open_Image.style.display='inline'; Codehighlighter1_694_837_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_694_837_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.cppblog.com/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_694_837_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        tempCount </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> GetMaxCountofContinuousLetter(p[i],searchChar);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">if</span>
								<span style="COLOR: #000000">( tempCount </span>
								<span style="COLOR: #000000">&gt;</span>
								<span style="COLOR: #000000"> maxCount)<br /><img id="Codehighlighter1_788_834_Open_Image" onclick="this.style.display='none'; Codehighlighter1_788_834_Open_Text.style.display='none'; Codehighlighter1_788_834_Closed_Image.style.display='inline'; Codehighlighter1_788_834_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_788_834_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_788_834_Closed_Text.style.display='none'; Codehighlighter1_788_834_Open_Image.style.display='inline'; Codehighlighter1_788_834_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
								<span id="Codehighlighter1_788_834_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
										<img src="http://www.cppblog.com/images/dot.gif" />
								</span>
								<span id="Codehighlighter1_788_834_Open_Text">
										<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            maxCount </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> tempCount;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            location </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> i;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
										<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    cout</span>
						<span style="COLOR: #000000">&lt;&lt;</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">the string of maxCount is : </span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">&lt;&lt;</span>
						<span style="COLOR: #000000">p[location]</span>
						<span style="COLOR: #000000">&lt;&lt;</span>
						<span style="COLOR: #000000">endl;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    cout</span>
						<span style="COLOR: #000000">&lt;&lt;</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">the count of  the continuous letters is : </span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">&lt;&lt;</span>
						<span style="COLOR: #000000">maxCount</span>
						<span style="COLOR: #000000">&lt;&lt;</span>
						<span style="COLOR: #000000">endl;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    cin.</span>
						<span style="COLOR: #0000ff">get</span>
						<span style="COLOR: #000000">();<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
		</div>
<img src ="http://www.cppblog.com/snowball/aggbug/45996.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/snowball/" target="_blank">snowball</a> 2008-04-02 09:30 <a href="http://www.cppblog.com/snowball/archive/2008/04/02/45996.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>排序</title><link>http://www.cppblog.com/snowball/archive/2008/04/02/45994.html</link><dc:creator>snowball</dc:creator><author>snowball</author><pubDate>Wed, 02 Apr 2008 01:26:00 GMT</pubDate><guid>http://www.cppblog.com/snowball/archive/2008/04/02/45994.html</guid><wfw:comment>http://www.cppblog.com/snowball/comments/45994.html</wfw:comment><comments>http://www.cppblog.com/snowball/archive/2008/04/02/45994.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/snowball/comments/commentRss/45994.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/snowball/services/trackbacks/45994.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 排序算法&nbsp;&nbsp;<a href='http://www.cppblog.com/snowball/archive/2008/04/02/45994.html'>阅读全文</a><img src ="http://www.cppblog.com/snowball/aggbug/45994.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/snowball/" target="_blank">snowball</a> 2008-04-02 09:26 <a href="http://www.cppblog.com/snowball/archive/2008/04/02/45994.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>从str中删除remove中含有的字符</title><link>http://www.cppblog.com/snowball/archive/2008/04/02/45993.html</link><dc:creator>snowball</dc:creator><author>snowball</author><pubDate>Wed, 02 Apr 2008 01:25:00 GMT</pubDate><guid>http://www.cppblog.com/snowball/archive/2008/04/02/45993.html</guid><wfw:comment>http://www.cppblog.com/snowball/comments/45993.html</wfw:comment><comments>http://www.cppblog.com/snowball/archive/2008/04/02/45993.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/snowball/comments/commentRss/45993.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/snowball/services/trackbacks/45993.html</trackback:ping><description><![CDATA[
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<img id="Codehighlighter1_0_43_Open_Image" onclick="this.style.display='none'; Codehighlighter1_0_43_Open_Text.style.display='none'; Codehighlighter1_0_43_Closed_Image.style.display='inline'; Codehighlighter1_0_43_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" />
				<img id="Codehighlighter1_0_43_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_0_43_Closed_Text.style.display='none'; Codehighlighter1_0_43_Open_Image.style.display='inline'; Codehighlighter1_0_43_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" />
				<span id="Codehighlighter1_0_43_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">/**/</span>
				<span id="Codehighlighter1_0_43_Open_Text">
						<span style="COLOR: #008000">/*</span>
						<span style="COLOR: #008000">****************************************</span>
						<span style="COLOR: #008000">*/</span>
				</span>
				<span style="COLOR: #000000">
						<br />
						<img id="Codehighlighter1_45_78_Open_Image" onclick="this.style.display='none'; Codehighlighter1_45_78_Open_Text.style.display='none'; Codehighlighter1_45_78_Closed_Image.style.display='inline'; Codehighlighter1_45_78_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" />
						<img id="Codehighlighter1_45_78_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_45_78_Closed_Text.style.display='none'; Codehighlighter1_45_78_Open_Image.style.display='inline'; Codehighlighter1_45_78_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" />
				</span>
				<span id="Codehighlighter1_45_78_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">/**/</span>
				<span id="Codehighlighter1_45_78_Open_Text">
						<span style="COLOR: #008000">/*</span>
						<span style="COLOR: #008000"> 从str中删除remove中含有的字符          </span>
						<span style="COLOR: #008000">*/</span>
				</span>
				<span style="COLOR: #000000">
						<br />
						<img id="Codehighlighter1_80_123_Open_Image" onclick="this.style.display='none'; Codehighlighter1_80_123_Open_Text.style.display='none'; Codehighlighter1_80_123_Closed_Image.style.display='inline'; Codehighlighter1_80_123_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" />
						<img id="Codehighlighter1_80_123_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_80_123_Closed_Text.style.display='none'; Codehighlighter1_80_123_Open_Image.style.display='inline'; Codehighlighter1_80_123_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" />
				</span>
				<span id="Codehighlighter1_80_123_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">/**/</span>
				<span id="Codehighlighter1_80_123_Open_Text">
						<span style="COLOR: #008000">/*</span>
						<span style="COLOR: #008000">****************************************</span>
						<span style="COLOR: #008000">*/</span>
				</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> RemoveChar(</span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> str[], </span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> remove[])<br /><img id="Codehighlighter1_168_581_Open_Image" onclick="this.style.display='none'; Codehighlighter1_168_581_Open_Text.style.display='none'; Codehighlighter1_168_581_Closed_Image.style.display='inline'; Codehighlighter1_168_581_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_168_581_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_168_581_Closed_Text.style.display='none'; Codehighlighter1_168_581_Open_Image.style.display='inline'; Codehighlighter1_168_581_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_168_581_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
						<img src="http://www.cppblog.com/images/dot.gif" />
				</span>
				<span id="Codehighlighter1_168_581_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> dst,src;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">char</span>
						<span style="COLOR: #000000"> removeArray[</span>
						<span style="COLOR: #000000">256</span>
						<span style="COLOR: #000000">];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    puts(str);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    puts(remove);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">for</span>
						<span style="COLOR: #000000">(src</span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">;src</span>
						<span style="COLOR: #000000">&lt;</span>
						<span style="COLOR: #000000">256</span>
						<span style="COLOR: #000000">;src</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_280_313_Open_Image" onclick="this.style.display='none'; Codehighlighter1_280_313_Open_Text.style.display='none'; Codehighlighter1_280_313_Closed_Image.style.display='inline'; Codehighlighter1_280_313_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_280_313_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_280_313_Closed_Text.style.display='none'; Codehighlighter1_280_313_Open_Image.style.display='inline'; Codehighlighter1_280_313_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_280_313_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.cppblog.com/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_280_313_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />       removeArray[src]</span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000">0</span>
								<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    src</span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">while</span>
						<span style="COLOR: #000000">(remove[src])<br /><img id="Codehighlighter1_353_396_Open_Image" onclick="this.style.display='none'; Codehighlighter1_353_396_Open_Text.style.display='none'; Codehighlighter1_353_396_Closed_Image.style.display='inline'; Codehighlighter1_353_396_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_353_396_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_353_396_Closed_Text.style.display='none'; Codehighlighter1_353_396_Open_Image.style.display='inline'; Codehighlighter1_353_396_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_353_396_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.cppblog.com/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_353_396_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />       removeArray[remove[src</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">]]</span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    src</span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">;dst</span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">while</span>
						<span style="COLOR: #000000">(str[src])<br /><img id="Codehighlighter1_439_548_Open_Image" onclick="this.style.display='none'; Codehighlighter1_439_548_Open_Text.style.display='none'; Codehighlighter1_439_548_Closed_Image.style.display='inline'; Codehighlighter1_439_548_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_439_548_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_439_548_Closed_Text.style.display='none'; Codehighlighter1_439_548_Open_Image.style.display='inline'; Codehighlighter1_439_548_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_439_548_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.cppblog.com/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_439_548_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">if</span>
								<span style="COLOR: #000000">(</span>
								<span style="COLOR: #000000">!</span>
								<span style="COLOR: #000000">removeArray[str[src]])<br /><img id="Codehighlighter1_484_527_Open_Image" onclick="this.style.display='none'; Codehighlighter1_484_527_Open_Text.style.display='none'; Codehighlighter1_484_527_Closed_Image.style.display='inline'; Codehighlighter1_484_527_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_484_527_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_484_527_Closed_Text.style.display='none'; Codehighlighter1_484_527_Open_Image.style.display='inline'; Codehighlighter1_484_527_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
								<span id="Codehighlighter1_484_527_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
										<img src="http://www.cppblog.com/images/dot.gif" />
								</span>
								<span id="Codehighlighter1_484_527_Open_Text">
										<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            str[dst</span>
										<span style="COLOR: #000000">++</span>
										<span style="COLOR: #000000">]</span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000">str[src];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
										<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        src</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    str[dst]</span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    puts(str);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
		</div>
<img src ="http://www.cppblog.com/snowball/aggbug/45993.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/snowball/" target="_blank">snowball</a> 2008-04-02 09:25 <a href="http://www.cppblog.com/snowball/archive/2008/04/02/45993.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Write a routine that prints out a 2-D array in spiral order</title><link>http://www.cppblog.com/snowball/archive/2008/04/02/45992.html</link><dc:creator>snowball</dc:creator><author>snowball</author><pubDate>Wed, 02 Apr 2008 01:23:00 GMT</pubDate><guid>http://www.cppblog.com/snowball/archive/2008/04/02/45992.html</guid><wfw:comment>http://www.cppblog.com/snowball/comments/45992.html</wfw:comment><comments>http://www.cppblog.com/snowball/archive/2008/04/02/45992.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/snowball/comments/commentRss/45992.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/snowball/services/trackbacks/45992.html</trackback:ping><description><![CDATA[
		<p>
				<font size="2">     jeccy (燕飞月天) 于 2006年10月28日21:37:09 星期六 提到：</font>
		</p>
		<p>
				<font size="2">我的理解，给定2维数组<br />1 2 3三角形判断<br />8 9 4<br />7 6 5<br />“螺旋式”顺序输出：1 2 3 4 5 6 7 8 9<br />【 在 bluexyz (数据结构是根本) 的大作中提到: 】</font>
		</p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">private</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">static</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> PrintNumberasSpiralOrder()<br /><img id="Codehighlighter1_56_1668_Open_Image" onclick="this.style.display='none'; Codehighlighter1_56_1668_Open_Text.style.display='none'; Codehighlighter1_56_1668_Closed_Image.style.display='inline'; Codehighlighter1_56_1668_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_56_1668_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_56_1668_Closed_Text.style.display='none'; Codehighlighter1_56_1668_Open_Image.style.display='inline'; Codehighlighter1_56_1668_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" />        </span>
				<span id="Codehighlighter1_56_1668_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
						<img src="http://www.cppblog.com/images/dot.gif" />
				</span>
				<span id="Codehighlighter1_56_1668_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
						<span style="COLOR: #008000">//</span>
						<span style="COLOR: #008000">1  2  3   4<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
						<span style="COLOR: #008000">//</span>
						<span style="COLOR: #008000">12 13 14  5<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
						<span style="COLOR: #008000">//</span>
						<span style="COLOR: #008000">11 16 15  6<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
						<span style="COLOR: #008000">//</span>
						<span style="COLOR: #008000">10 9   8  7<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
						<span style="COLOR: #008000">//</span>
						<span style="COLOR: #008000">1,  2 , 3,  4,  5<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
						<span style="COLOR: #008000">//</span>
						<span style="COLOR: #008000">16, 17, 18, 19, 6<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
						<span style="COLOR: #008000">//</span>
						<span style="COLOR: #008000">15, 24, 25, 20, 7<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
						<span style="COLOR: #008000">//</span>
						<span style="COLOR: #008000">14, 23, 22, 21, 8<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
						<span style="COLOR: #008000">//</span>
						<span style="COLOR: #008000">13, 12, 11, 10, 9</span>
						<span style="COLOR: #008000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
						</span>
						<span style="COLOR: #000000">            </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000">[,] a </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">new</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000">[,]<br /><img id="Codehighlighter1_381_543_Open_Image" onclick="this.style.display='none'; Codehighlighter1_381_543_Open_Text.style.display='none'; Codehighlighter1_381_543_Closed_Image.style.display='inline'; Codehighlighter1_381_543_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_381_543_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_381_543_Closed_Text.style.display='none'; Codehighlighter1_381_543_Open_Image.style.display='inline'; Codehighlighter1_381_543_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />            </span>
						<span id="Codehighlighter1_381_543_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.cppblog.com/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_381_543_Open_Text">
								<span style="COLOR: #000000">{ </span>
								<span id="Codehighlighter1_383_399_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
										<img src="http://www.cppblog.com/images/dot.gif" />
								</span>
								<span id="Codehighlighter1_383_399_Open_Text">
										<span style="COLOR: #000000">{ </span>
										<span style="COLOR: #000000">1</span>
										<span style="COLOR: #000000">, </span>
										<span style="COLOR: #000000">2</span>
										<span style="COLOR: #000000">, </span>
										<span style="COLOR: #000000">3</span>
										<span style="COLOR: #000000">, </span>
										<span style="COLOR: #000000">4</span>
										<span style="COLOR: #000000">, </span>
										<span style="COLOR: #000000">5</span>
										<span style="COLOR: #000000"> }</span>
								</span>
								<span style="COLOR: #000000">, <br /><img id="Codehighlighter1_415_435_Open_Image" onclick="this.style.display='none'; Codehighlighter1_415_435_Open_Text.style.display='none'; Codehighlighter1_415_435_Closed_Image.style.display='inline'; Codehighlighter1_415_435_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_415_435_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_415_435_Closed_Text.style.display='none'; Codehighlighter1_415_435_Open_Image.style.display='inline'; Codehighlighter1_415_435_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />            </span>
								<span id="Codehighlighter1_415_435_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
										<img src="http://www.cppblog.com/images/dot.gif" />
								</span>
								<span id="Codehighlighter1_415_435_Open_Text">
										<span style="COLOR: #000000">{ </span>
										<span style="COLOR: #000000">16</span>
										<span style="COLOR: #000000">, </span>
										<span style="COLOR: #000000">17</span>
										<span style="COLOR: #000000">, </span>
										<span style="COLOR: #000000">18</span>
										<span style="COLOR: #000000">, </span>
										<span style="COLOR: #000000">19</span>
										<span style="COLOR: #000000">, </span>
										<span style="COLOR: #000000">6</span>
										<span style="COLOR: #000000"> }</span>
								</span>
								<span style="COLOR: #000000">, <br /><img id="Codehighlighter1_451_471_Open_Image" onclick="this.style.display='none'; Codehighlighter1_451_471_Open_Text.style.display='none'; Codehighlighter1_451_471_Closed_Image.style.display='inline'; Codehighlighter1_451_471_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_451_471_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_451_471_Closed_Text.style.display='none'; Codehighlighter1_451_471_Open_Image.style.display='inline'; Codehighlighter1_451_471_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />            </span>
								<span id="Codehighlighter1_451_471_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
										<img src="http://www.cppblog.com/images/dot.gif" />
								</span>
								<span id="Codehighlighter1_451_471_Open_Text">
										<span style="COLOR: #000000">{ </span>
										<span style="COLOR: #000000">15</span>
										<span style="COLOR: #000000">, </span>
										<span style="COLOR: #000000">24</span>
										<span style="COLOR: #000000">, </span>
										<span style="COLOR: #000000">25</span>
										<span style="COLOR: #000000">, </span>
										<span style="COLOR: #000000">20</span>
										<span style="COLOR: #000000">, </span>
										<span style="COLOR: #000000">7</span>
										<span style="COLOR: #000000"> }</span>
								</span>
								<span style="COLOR: #000000">,<br /><img id="Codehighlighter1_486_506_Open_Image" onclick="this.style.display='none'; Codehighlighter1_486_506_Open_Text.style.display='none'; Codehighlighter1_486_506_Closed_Image.style.display='inline'; Codehighlighter1_486_506_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_486_506_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_486_506_Closed_Text.style.display='none'; Codehighlighter1_486_506_Open_Image.style.display='inline'; Codehighlighter1_486_506_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />            </span>
								<span id="Codehighlighter1_486_506_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
										<img src="http://www.cppblog.com/images/dot.gif" />
								</span>
								<span id="Codehighlighter1_486_506_Open_Text">
										<span style="COLOR: #000000">{ </span>
										<span style="COLOR: #000000">14</span>
										<span style="COLOR: #000000">, </span>
										<span style="COLOR: #000000">23</span>
										<span style="COLOR: #000000">, </span>
										<span style="COLOR: #000000">22</span>
										<span style="COLOR: #000000">, </span>
										<span style="COLOR: #000000">21</span>
										<span style="COLOR: #000000">, </span>
										<span style="COLOR: #000000">8</span>
										<span style="COLOR: #000000"> }</span>
								</span>
								<span style="COLOR: #000000">,<br /><img id="Codehighlighter1_521_541_Open_Image" onclick="this.style.display='none'; Codehighlighter1_521_541_Open_Text.style.display='none'; Codehighlighter1_521_541_Closed_Image.style.display='inline'; Codehighlighter1_521_541_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_521_541_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_521_541_Closed_Text.style.display='none'; Codehighlighter1_521_541_Open_Image.style.display='inline'; Codehighlighter1_521_541_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />            </span>
								<span id="Codehighlighter1_521_541_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
										<img src="http://www.cppblog.com/images/dot.gif" />
								</span>
								<span id="Codehighlighter1_521_541_Open_Text">
										<span style="COLOR: #000000">{ </span>
										<span style="COLOR: #000000">13</span>
										<span style="COLOR: #000000">, </span>
										<span style="COLOR: #000000">12</span>
										<span style="COLOR: #000000">, </span>
										<span style="COLOR: #000000">11</span>
										<span style="COLOR: #000000">, </span>
										<span style="COLOR: #000000">10</span>
										<span style="COLOR: #000000">, </span>
										<span style="COLOR: #000000">9</span>
										<span style="COLOR: #000000"> }</span>
								</span>
								<span style="COLOR: #000000"> }</span>
						</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
						<span style="COLOR: #008000">//</span>
						<span style="COLOR: #008000">int[,] a = new int[,] { { 1, 2, 3, 4 }, { 12, 13, 14, 5 }, { 11, 16, 15, 6 }, { 10, 9, 8, 7 } };<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
						<span style="COLOR: #008000">//</span>
						<span style="COLOR: #008000">int[,] a = new int[,] { { 1, 2 }, {4,3} };</span>
						<span style="COLOR: #008000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
						</span>
						<span style="COLOR: #000000">            </span>
						<span style="COLOR: #0000ff">const</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> N </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">5</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
						<span style="COLOR: #008000">//</span>
						<span style="COLOR: #008000"> spiral</span>
						<span style="COLOR: #008000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
						</span>
						<span style="COLOR: #000000">            </span>
						<span style="COLOR: #0000ff">for</span>
						<span style="COLOR: #000000"> (</span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> i </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> N </span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">, j </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">; i </span>
						<span style="COLOR: #000000">&gt;</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">; i</span>
						<span style="COLOR: #000000">--</span>
						<span style="COLOR: #000000">, j</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_833_1490_Open_Image" onclick="this.style.display='none'; Codehighlighter1_833_1490_Open_Text.style.display='none'; Codehighlighter1_833_1490_Closed_Image.style.display='inline'; Codehighlighter1_833_1490_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_833_1490_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_833_1490_Closed_Text.style.display='none'; Codehighlighter1_833_1490_Open_Image.style.display='inline'; Codehighlighter1_833_1490_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />            </span>
						<span id="Codehighlighter1_833_1490_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.cppblog.com/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_833_1490_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                </span>
								<span style="COLOR: #008000">//</span>
								<span style="COLOR: #008000">i 从最大维度数开始<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                </span>
								<span style="COLOR: #008000">//</span>
								<span style="COLOR: #008000">j 从最小维度数开始<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                </span>
								<span style="COLOR: #008000">//</span>
								<span style="COLOR: #008000">i--来缩小范围<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                </span>
								<span style="COLOR: #008000">//</span>
								<span style="COLOR: #008000">j++来缩小范围<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                </span>
								<span style="COLOR: #008000">//</span>
								<span style="COLOR: #008000">k 增长缩小因子</span>
								<span style="COLOR: #008000">
										<br />
										<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
								</span>
								<span style="COLOR: #000000">                </span>
								<span style="COLOR: #0000ff">for</span>
								<span style="COLOR: #000000"> (</span>
								<span style="COLOR: #0000ff">int</span>
								<span style="COLOR: #000000"> k </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> j; k </span>
								<span style="COLOR: #000000">&lt;</span>
								<span style="COLOR: #000000"> i; k</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                    System.Console.Write(</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">{0} </span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">, a[j, k]); Console.WriteLine(</span>
								<span style="COLOR: #000000">""</span>
								<span style="COLOR: #000000">);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                </span>
								<span style="COLOR: #0000ff">for</span>
								<span style="COLOR: #000000"> (</span>
								<span style="COLOR: #0000ff">int</span>
								<span style="COLOR: #000000"> k </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> j; k </span>
								<span style="COLOR: #000000">&lt;</span>
								<span style="COLOR: #000000"> i; k</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                    System.Console.Write(</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">{0} </span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">, a[k, i]); Console.WriteLine(</span>
								<span style="COLOR: #000000">""</span>
								<span style="COLOR: #000000">);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                </span>
								<span style="COLOR: #0000ff">for</span>
								<span style="COLOR: #000000"> (</span>
								<span style="COLOR: #0000ff">int</span>
								<span style="COLOR: #000000"> k </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> i; k </span>
								<span style="COLOR: #000000">&gt;</span>
								<span style="COLOR: #000000"> j; k</span>
								<span style="COLOR: #000000">--</span>
								<span style="COLOR: #000000">)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                    System.Console.Write(</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">{0} </span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">, a[i, k]); Console.WriteLine(</span>
								<span style="COLOR: #000000">""</span>
								<span style="COLOR: #000000">);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                </span>
								<span style="COLOR: #0000ff">for</span>
								<span style="COLOR: #000000"> (</span>
								<span style="COLOR: #0000ff">int</span>
								<span style="COLOR: #000000"> k </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> i; k </span>
								<span style="COLOR: #000000">&gt;</span>
								<span style="COLOR: #000000"> j; k</span>
								<span style="COLOR: #000000">--</span>
								<span style="COLOR: #000000">)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                    System.Console.Write(</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">{0} </span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">, a[k, j]); Console.WriteLine(</span>
								<span style="COLOR: #000000">""</span>
								<span style="COLOR: #000000">);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />            }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
						<span style="COLOR: #008000">//</span>
						<span style="COLOR: #008000"> special case for middle element if N is odd<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
						<span style="COLOR: #008000">//</span>
						<span style="COLOR: #008000">如果是奇数，则要条印中间的数。</span>
						<span style="COLOR: #008000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
						</span>
						<span style="COLOR: #000000">            </span>
						<span style="COLOR: #0000ff">if</span>
						<span style="COLOR: #000000"> (N </span>
						<span style="COLOR: #000000">%</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">2</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">==</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">) System.Console.Write(a[(N </span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">) </span>
						<span style="COLOR: #000000">/</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">2</span>
						<span style="COLOR: #000000">, (N </span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">) </span>
						<span style="COLOR: #000000">/</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">2</span>
						<span style="COLOR: #000000">]);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />        }</span>
				</span>
		</div>
		<br />Reference : <a href="http://bigtiger2005.spaces.live.com/blog/cns!4e967c6fe38e7c14!141.entry?wa=wsignin1.0">http://bigtiger2005.spaces.live.com/blog/cns!4e967c6fe38e7c14!141.entry?wa=wsignin1.0</a><img src ="http://www.cppblog.com/snowball/aggbug/45992.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/snowball/" target="_blank">snowball</a> 2008-04-02 09:23 <a href="http://www.cppblog.com/snowball/archive/2008/04/02/45992.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>100扇门，100个人，第i个人经过门号可以整除i的门。经过时，如果门开就关，如果门关就开。问最后所有门的状态是什么。</title><link>http://www.cppblog.com/snowball/archive/2008/04/02/45990.html</link><dc:creator>snowball</dc:creator><author>snowball</author><pubDate>Wed, 02 Apr 2008 01:20:00 GMT</pubDate><guid>http://www.cppblog.com/snowball/archive/2008/04/02/45990.html</guid><wfw:comment>http://www.cppblog.com/snowball/comments/45990.html</wfw:comment><comments>http://www.cppblog.com/snowball/archive/2008/04/02/45990.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/snowball/comments/commentRss/45990.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/snowball/services/trackbacks/45990.html</trackback:ping><description><![CDATA[
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #000000">#include   </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">stdio.h</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000"> <br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">#define</span>
				<span style="COLOR: #000000">   N   100 </span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">#define</span>
				<span style="COLOR: #000000">   OPEN   1 </span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">#define</span>
				<span style="COLOR: #000000">   CLOSED   0 </span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000">   switch_door(</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000">   </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">door) <br /><img id="Codehighlighter1_118_238_Open_Image" onclick="this.style.display='none'; Codehighlighter1_118_238_Open_Text.style.display='none'; Codehighlighter1_118_238_Closed_Image.style.display='inline'; Codehighlighter1_118_238_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_118_238_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_118_238_Closed_Text.style.display='none'; Codehighlighter1_118_238_Open_Image.style.display='inline'; Codehighlighter1_118_238_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_118_238_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
						<img src="http://www.cppblog.com/images/dot.gif" />
				</span>
				<span id="Codehighlighter1_118_238_Open_Text">
						<span style="COLOR: #000000">{ <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
						<span style="COLOR: #0000ff">if</span>
						<span style="COLOR: #000000">(</span>
						<span style="COLOR: #000000">*</span>
						<span style="COLOR: #000000">door   </span>
						<span style="COLOR: #000000">==</span>
						<span style="COLOR: #000000">   OPEN) <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                </span>
						<span style="COLOR: #000000">*</span>
						<span style="COLOR: #000000">door   </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000">   CLOSED; <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
						<span style="COLOR: #0000ff">else</span>
						<span style="COLOR: #000000"> <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                </span>
						<span style="COLOR: #000000">*</span>
						<span style="COLOR: #000000">door   </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000">   OPEN; <br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000"> <br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000">   main(</span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000">) <br /><img id="Codehighlighter1_260_918_Open_Image" onclick="this.style.display='none'; Codehighlighter1_260_918_Open_Text.style.display='none'; Codehighlighter1_260_918_Closed_Image.style.display='inline'; Codehighlighter1_260_918_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_260_918_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_260_918_Closed_Text.style.display='none'; Codehighlighter1_260_918_Open_Image.style.display='inline'; Codehighlighter1_260_918_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_260_918_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
						<img src="http://www.cppblog.com/images/dot.gif" />
				</span>
				<span id="Codehighlighter1_260_918_Open_Text">
						<span style="COLOR: #000000">{ <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000">   door[N   </span>
						<span style="COLOR: #000000">+</span>
						<span style="COLOR: #000000">   </span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">];   </span>
						<span style="COLOR: #008000">//</span>
						<span style="COLOR: #008000">   waste   a   door </span>
						<span style="COLOR: #008000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
						</span>
						<span style="COLOR: #000000">        </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000">   person; <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000">   i; <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
						<span style="COLOR: #0000ff">for</span>
						<span style="COLOR: #000000">(i   </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000">   </span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">;   i   </span>
						<span style="COLOR: #000000">&lt;=</span>
						<span style="COLOR: #000000">   N;   i</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">) <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                door[i]   </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000">   OPEN;   </span>
						<span style="COLOR: #008000">//</span>
						<span style="COLOR: #008000">   all   doors   are   open   at   first </span>
						<span style="COLOR: #008000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
						<span style="COLOR: #0000ff">for</span>
						<span style="COLOR: #000000">(i   </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000">   </span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">;   i   </span>
						<span style="COLOR: #000000">&lt;=</span>
						<span style="COLOR: #000000">   N;   i</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">) <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                </span>
						<span style="COLOR: #0000ff">for</span>
						<span style="COLOR: #000000">(person   </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000">   </span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">;   person   </span>
						<span style="COLOR: #000000">&lt;=</span>
						<span style="COLOR: #000000">   N;   person</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)   </span>
						<span style="COLOR: #008000">//</span>
						<span style="COLOR: #008000">   person   pass   through   the   door </span>
						<span style="COLOR: #008000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
						</span>
						<span style="COLOR: #000000">                        </span>
						<span style="COLOR: #0000ff">if</span>
						<span style="COLOR: #000000">(i   </span>
						<span style="COLOR: #000000">%</span>
						<span style="COLOR: #000000">   person   </span>
						<span style="COLOR: #000000">==</span>
						<span style="COLOR: #000000">   </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">) <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                                switch_door(</span>
						<span style="COLOR: #000000">&amp;</span>
						<span style="COLOR: #000000">door[i]); <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
						<span style="COLOR: #0000ff">for</span>
						<span style="COLOR: #000000">(i   </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000">   </span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">;   i   </span>
						<span style="COLOR: #000000">&lt;=</span>
						<span style="COLOR: #000000">   N;   i</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">) <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                printf( </span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">door   %d:   %s\n </span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">,   i,   door[i]   </span>
						<span style="COLOR: #000000">?</span>
						<span style="COLOR: #000000">   </span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">Open </span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">   :   </span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">Closed </span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">); <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
						<span style="COLOR: #0000ff">return</span>
						<span style="COLOR: #000000">   </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">; <br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000"> <br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
		</div>
		<font face="Arial" size="2">给一个此题的思想： <br />要看门的状态，主要是看这扇门开关次数，开关奇数次会使门的状态改变，而偶数次就不会。而只要能够知道当前门的编号能够整除的自然数，就可以知道门的状态是否改变了。从而知道门当最终的状态。 <br /><br />下面我们将所有的数分为两组，平方数（1，4，9……）和非平方数（为什么要这么分？下面就知道了）。 <br />现在讨论非平方数的情况。我们假设门号为N,同时假设从1开始到int(N^(1/2))(也就是N的开方数舍小数取整），总共有M个数能整除N,则从int(N^(1/2))+1到N,总共则对应也有M个数能够将N整除。（这句话仔细想一下）。 <br />在此，就有2*M个数能将N整除，它是一个偶数。因此门开关了偶数次，门的状态最后不会被改变。 <br /><br />现在讨论平方数，因为N^(1/2)这个数是一个整数，因此我们将从1到N的所有的数用N^(1/2)这个数分成两部分(不包括N^(1/2))，同样假设前半部分有M个数可以将N整除，则后半部分也有M个数可以将N整除，这样就有2*M个数可以整除N了，再加上N^(1/2)这个数。总共就有2*M+1个数可以整除N,也就是编号为N的门会开关2*M+1次，门的状态就会被改变了。 <br /><br />综上，如果门号数是平方数的，门的状态就会发生改变，而不是平方数的就不会改变状态了。因此，只要检查门是否为完全平方数就可以判断门的状态为开还是为关了。</font>
		<br />
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #000000">帖上代码： <br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />#include   </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">iostream</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000"> <br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />#include   </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">cmath</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000"> <br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">using</span>
				<span style="COLOR: #000000">   </span>
				<span style="COLOR: #0000ff">namespace</span>
				<span style="COLOR: #000000">   std; <br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000">   main() <br /><img id="Codehighlighter1_91_414_Open_Image" onclick="this.style.display='none'; Codehighlighter1_91_414_Open_Text.style.display='none'; Codehighlighter1_91_414_Closed_Image.style.display='inline'; Codehighlighter1_91_414_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_91_414_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_91_414_Closed_Text.style.display='none'; Codehighlighter1_91_414_Open_Image.style.display='inline'; Codehighlighter1_91_414_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_91_414_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
						<img src="http://www.cppblog.com/images/dot.gif" />
				</span>
				<span id="Codehighlighter1_91_414_Open_Text">
						<span style="COLOR: #000000">{ <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000">   k; <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
						<span style="COLOR: #0000ff">for</span>
						<span style="COLOR: #000000">(</span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000">   i   </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000">   </span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">;   i   </span>
						<span style="COLOR: #000000">&lt;=</span>
						<span style="COLOR: #000000">100</span>
						<span style="COLOR: #000000">;   i</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">) <br /><img id="Codehighlighter1_170_398_Open_Image" onclick="this.style.display='none'; Codehighlighter1_170_398_Open_Text.style.display='none'; Codehighlighter1_170_398_Closed_Image.style.display='inline'; Codehighlighter1_170_398_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_170_398_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_170_398_Closed_Text.style.display='none'; Codehighlighter1_170_398_Open_Image.style.display='inline'; Codehighlighter1_170_398_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
						<span id="Codehighlighter1_170_398_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.cppblog.com/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_170_398_Open_Text">
								<span style="COLOR: #000000">{ <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        cout   </span>
								<span style="COLOR: #000000">&lt;</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">&lt;</span>
								<span style="COLOR: #000000">   </span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">Door   </span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">   </span>
								<span style="COLOR: #000000">&lt;</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">&lt;</span>
								<span style="COLOR: #000000">   i   ; <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        k   </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000">   </span>
								<span style="COLOR: #0000ff">int</span>
								<span style="COLOR: #000000">(sqrt(i)); <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">if</span>
								<span style="COLOR: #000000">(k</span>
								<span style="COLOR: #000000">*</span>
								<span style="COLOR: #000000">k   </span>
								<span style="COLOR: #000000">==</span>
								<span style="COLOR: #000000">   i) <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        cout   </span>
								<span style="COLOR: #000000">&lt;</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">&lt;</span>
								<span style="COLOR: #000000">   </span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">:   Closed </span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">; <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">else</span>
								<span style="COLOR: #000000"> <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        cout   </span>
								<span style="COLOR: #000000">&lt;</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">&lt;</span>
								<span style="COLOR: #000000">   </span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">:   Open </span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">; <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        cout   </span>
								<span style="COLOR: #000000">&lt;</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">&lt;</span>
								<span style="COLOR: #000000">   endl; <br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
						</span>
						<span style="COLOR: #000000"> <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /></span>
						<span style="COLOR: #0000ff">return</span>
						<span style="COLOR: #000000">   </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">; <br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000"> <br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />当然，这是利用了人数与门数是相等的情况。如果个数不同的话，还是按照一楼的来。</span>
		</div>
		<br />Reference : <a href="http://topic.csdn.net/u/20070620/14/3d5e96d5-169a-4bc6-887c-ca8639cd8c63.html">http://topic.csdn.net/u/20070620/14/3d5e96d5-169a-4bc6-887c-ca8639cd8c63.html</a><img src ="http://www.cppblog.com/snowball/aggbug/45990.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/snowball/" target="_blank">snowball</a> 2008-04-02 09:20 <a href="http://www.cppblog.com/snowball/archive/2008/04/02/45990.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>统计1的个数</title><link>http://www.cppblog.com/snowball/archive/2008/04/02/45989.html</link><dc:creator>snowball</dc:creator><author>snowball</author><pubDate>Wed, 02 Apr 2008 01:17:00 GMT</pubDate><guid>http://www.cppblog.com/snowball/archive/2008/04/02/45989.html</guid><wfw:comment>http://www.cppblog.com/snowball/comments/45989.html</wfw:comment><comments>http://www.cppblog.com/snowball/archive/2008/04/02/45989.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/snowball/comments/commentRss/45989.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/snowball/services/trackbacks/45989.html</trackback:ping><description><![CDATA[
		<p>统计1的个数</p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> func(x)<br /><img id="Codehighlighter1_12_117_Open_Image" onclick="this.style.display='none'; Codehighlighter1_12_117_Open_Text.style.display='none'; Codehighlighter1_12_117_Closed_Image.style.display='inline'; Codehighlighter1_12_117_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_12_117_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_12_117_Closed_Text.style.display='none'; Codehighlighter1_12_117_Open_Image.style.display='inline'; Codehighlighter1_12_117_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_12_117_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
						<img src="http://www.cppblog.com/images/dot.gif" />
				</span>
				<span id="Codehighlighter1_12_117_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> countx </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">while</span>
						<span style="COLOR: #000000">(x)<br /><img id="Codehighlighter1_51_96_Open_Image" onclick="this.style.display='none'; Codehighlighter1_51_96_Open_Text.style.display='none'; Codehighlighter1_51_96_Closed_Image.style.display='inline'; Codehighlighter1_51_96_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_51_96_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_51_96_Closed_Text.style.display='none'; Codehighlighter1_51_96_Open_Image.style.display='inline'; Codehighlighter1_51_96_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_51_96_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.cppblog.com/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_51_96_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        countx</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        x </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> x</span>
								<span style="COLOR: #000000">&amp;</span>
								<span style="COLOR: #000000">(x</span>
								<span style="COLOR: #000000">-</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">return</span>
						<span style="COLOR: #000000"> countx;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000"> <br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />假定x </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">9999</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000">10011100001111</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />答案: </span>
				<span style="COLOR: #000000">8</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />将x转化为2进制，看含有的1的个数<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />x</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">x</span>
				<span style="COLOR: #000000">&amp;</span>
				<span style="COLOR: #000000">(x</span>
				<span style="COLOR: #000000">-</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">) 这种算法是把一个二进制数最右边的一个1变成0<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />然后呢？<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />x</span>
				<span style="COLOR: #000000">-</span>
				<span style="COLOR: #000000">1与x区别在于最后二进制的1<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />每执行一次x </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> x</span>
				<span style="COLOR: #000000">&amp;</span>
				<span style="COLOR: #000000">(x</span>
				<span style="COLOR: #000000">-</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">)，会将x用二进制表示时最右边的一个1变为0，因为x</span>
				<span style="COLOR: #000000">-</span>
				<span style="COLOR: #000000">1将会将该位(x用二进制表示时最右边的一个1)变为0。<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />如果是二进制100,</span>
				<span style="COLOR: #000000">-</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">，则为011<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />如果是二进制101，</span>
				<span style="COLOR: #000000">-</span>
				<span style="COLOR: #000000">1则为100<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />与原数一与，就1后面的数，包括1全都与掉<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />明白，谢谢了 <br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />不客气</span>
		</div>
		<p>
				<br />思路: 将x转化为2进制，看含有的1的个数。<br />注: 每执行一次x = x&amp;(x-1)，会将x用二进制表示时最右边的一个1变为0，因为x-1将会将该位(x用二进制表示时最右边的一个1)变为0。(1) 如果一个数是2的n次方，那么这个数用二进制表示时其最高位为1，其余位为0。<br />判断一个数(x)是否是2的n次方<br /><br /></p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #000000">#include </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">stdio.h</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> func(x)<br /><img id="Codehighlighter1_32_104_Open_Image" onclick="this.style.display='none'; Codehighlighter1_32_104_Open_Text.style.display='none'; Codehighlighter1_32_104_Closed_Image.style.display='inline'; Codehighlighter1_32_104_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_32_104_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_32_104_Closed_Text.style.display='none'; Codehighlighter1_32_104_Open_Image.style.display='inline'; Codehighlighter1_32_104_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_32_104_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
						<img src="http://www.cppblog.com/images/dot.gif" />
				</span>
				<span id="Codehighlighter1_32_104_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">if</span>
						<span style="COLOR: #000000">( (x</span>
						<span style="COLOR: #000000">&amp;</span>
						<span style="COLOR: #000000">(x</span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">)) </span>
						<span style="COLOR: #000000">==</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000"> )<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
						<span style="COLOR: #0000ff">return</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">else</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
						<span style="COLOR: #0000ff">return</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> main()<br /><img id="Codehighlighter1_118_166_Open_Image" onclick="this.style.display='none'; Codehighlighter1_118_166_Open_Text.style.display='none'; Codehighlighter1_118_166_Closed_Image.style.display='inline'; Codehighlighter1_118_166_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_118_166_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_118_166_Closed_Text.style.display='none'; Codehighlighter1_118_166_Open_Image.style.display='inline'; Codehighlighter1_118_166_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_118_166_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
						<img src="http://www.cppblog.com/images/dot.gif" />
				</span>
				<span id="Codehighlighter1_118_166_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> x </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">8</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    printf(</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">%d\n</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">, func(x));<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" /> }</span>
				</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
		</div>
<img src ="http://www.cppblog.com/snowball/aggbug/45989.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/snowball/" target="_blank">snowball</a> 2008-04-02 09:17 <a href="http://www.cppblog.com/snowball/archive/2008/04/02/45989.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>全排列的生成算法</title><link>http://www.cppblog.com/snowball/archive/2008/04/02/45987.html</link><dc:creator>snowball</dc:creator><author>snowball</author><pubDate>Wed, 02 Apr 2008 01:06:00 GMT</pubDate><guid>http://www.cppblog.com/snowball/archive/2008/04/02/45987.html</guid><wfw:comment>http://www.cppblog.com/snowball/comments/45987.html</wfw:comment><comments>http://www.cppblog.com/snowball/archive/2008/04/02/45987.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/snowball/comments/commentRss/45987.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/snowball/services/trackbacks/45987.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 全排列的生成算法就是对于给定的字符集，用有效的方法将所有可能的全排列无重复无遗漏地枚举出来。任何n个字符集的排列都可以与1～n的n个数字的排列一一对应，因此在此就以n个数字的排列为例说明排列的生成法。n个字符的全体排列之间存在一个确定的线性顺序关系。所有的排列中除最后一个排列外，都有一个后继；除第一个排列外，都有一个前驱。每个排列的后继都可以从 它 的前驱经过最少的变化而得到，全排列的生成算法就是...&nbsp;&nbsp;<a href='http://www.cppblog.com/snowball/archive/2008/04/02/45987.html'>阅读全文</a><img src ="http://www.cppblog.com/snowball/aggbug/45987.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/snowball/" target="_blank">snowball</a> 2008-04-02 09:06 <a href="http://www.cppblog.com/snowball/archive/2008/04/02/45987.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>进制转换程序</title><link>http://www.cppblog.com/snowball/archive/2008/04/02/45985.html</link><dc:creator>snowball</dc:creator><author>snowball</author><pubDate>Wed, 02 Apr 2008 01:02:00 GMT</pubDate><guid>http://www.cppblog.com/snowball/archive/2008/04/02/45985.html</guid><wfw:comment>http://www.cppblog.com/snowball/comments/45985.html</wfw:comment><comments>http://www.cppblog.com/snowball/archive/2008/04/02/45985.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/snowball/comments/commentRss/45985.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/snowball/services/trackbacks/45985.html</trackback:ping><description><![CDATA[
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> test10_2(</span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_23_413_Open_Image" onclick="this.style.display='none'; Codehighlighter1_23_413_Open_Text.style.display='none'; Codehighlighter1_23_413_Closed_Image.style.display='inline'; Codehighlighter1_23_413_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_23_413_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_23_413_Closed_Text.style.display='none'; Codehighlighter1_23_413_Open_Image.style.display='inline'; Codehighlighter1_23_413_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" />  </span>
				<span id="Codehighlighter1_23_413_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
						<img src="http://www.cppblog.com/images/dot.gif" />
				</span>
				<span id="Codehighlighter1_23_413_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />   </span>
						<span style="COLOR: #0000ff">static</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">char</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">const</span>
						<span style="COLOR: #000000">*</span>
						<span style="COLOR: #000000"> szHexDigits </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">01</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />   unsigned </span>
						<span style="COLOR: #0000ff">char</span>
						<span style="COLOR: #000000"> b </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">16</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />   cout </span>
						<span style="COLOR: #000000">&lt;&lt;</span>
						<span style="COLOR: #000000"> szHexDigits[(b </span>
						<span style="COLOR: #000000">&gt;&gt;</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">7</span>
						<span style="COLOR: #000000">) </span>
						<span style="COLOR: #000000">&amp;</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0x01</span>
						<span style="COLOR: #000000">] </span>
						<span style="COLOR: #000000">&lt;&lt;</span>
						<span style="COLOR: #000000"> szHexDigits[(b </span>
						<span style="COLOR: #000000">&gt;&gt;</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">6</span>
						<span style="COLOR: #000000">) </span>
						<span style="COLOR: #000000">&amp;</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0x01</span>
						<span style="COLOR: #000000">] </span>
						<span style="COLOR: #000000">&lt;&lt;</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />   cout </span>
						<span style="COLOR: #000000">&lt;&lt;</span>
						<span style="COLOR: #000000"> szHexDigits[(b </span>
						<span style="COLOR: #000000">&gt;&gt;</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">5</span>
						<span style="COLOR: #000000">) </span>
						<span style="COLOR: #000000">&amp;</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0x01</span>
						<span style="COLOR: #000000">] </span>
						<span style="COLOR: #000000">&lt;&lt;</span>
						<span style="COLOR: #000000"> szHexDigits[(b </span>
						<span style="COLOR: #000000">&gt;&gt;</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">4</span>
						<span style="COLOR: #000000">) </span>
						<span style="COLOR: #000000">&amp;</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0x01</span>
						<span style="COLOR: #000000">] </span>
						<span style="COLOR: #000000">&lt;&lt;</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />   cout </span>
						<span style="COLOR: #000000">&lt;&lt;</span>
						<span style="COLOR: #000000"> szHexDigits[(b </span>
						<span style="COLOR: #000000">&gt;&gt;</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">3</span>
						<span style="COLOR: #000000">) </span>
						<span style="COLOR: #000000">&amp;</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0x01</span>
						<span style="COLOR: #000000">] </span>
						<span style="COLOR: #000000">&lt;&lt;</span>
						<span style="COLOR: #000000"> szHexDigits[(b </span>
						<span style="COLOR: #000000">&gt;&gt;</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">2</span>
						<span style="COLOR: #000000">) </span>
						<span style="COLOR: #000000">&amp;</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0x01</span>
						<span style="COLOR: #000000">] </span>
						<span style="COLOR: #000000">&lt;&lt;</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />   cout </span>
						<span style="COLOR: #000000">&lt;&lt;</span>
						<span style="COLOR: #000000"> szHexDigits[(b </span>
						<span style="COLOR: #000000">&gt;&gt;</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">) </span>
						<span style="COLOR: #000000">&amp;</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0x01</span>
						<span style="COLOR: #000000">] </span>
						<span style="COLOR: #000000">&lt;&lt;</span>
						<span style="COLOR: #000000"> szHexDigits[(b </span>
						<span style="COLOR: #000000">&gt;&gt;</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">) </span>
						<span style="COLOR: #000000">&amp;</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0x01</span>
						<span style="COLOR: #000000">] </span>
						<span style="COLOR: #000000">&lt;&lt;</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" /> }</span>
				</span>
		</div>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> test10_16(</span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_24_185_Open_Image" onclick="this.style.display='none'; Codehighlighter1_24_185_Open_Text.style.display='none'; Codehighlighter1_24_185_Closed_Image.style.display='inline'; Codehighlighter1_24_185_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_24_185_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_24_185_Closed_Text.style.display='none'; Codehighlighter1_24_185_Open_Image.style.display='inline'; Codehighlighter1_24_185_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" />  </span>
				<span id="Codehighlighter1_24_185_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
						<img src="http://www.cppblog.com/images/dot.gif" />
				</span>
				<span id="Codehighlighter1_24_185_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">static</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">char</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">const</span>
						<span style="COLOR: #000000">*</span>
						<span style="COLOR: #000000"> szHexDigits </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">0123456789abcdef</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">;   <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />   unsigned </span>
						<span style="COLOR: #0000ff">char</span>
						<span style="COLOR: #000000"> b </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">16</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />   cout </span>
						<span style="COLOR: #000000">&lt;&lt;</span>
						<span style="COLOR: #000000"> szHexDigits[(b </span>
						<span style="COLOR: #000000">&gt;&gt;</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">4</span>
						<span style="COLOR: #000000">) </span>
						<span style="COLOR: #000000">&amp;</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0x0f</span>
						<span style="COLOR: #000000">] </span>
						<span style="COLOR: #000000">&lt;&lt;</span>
						<span style="COLOR: #000000"> szHexDigits[b </span>
						<span style="COLOR: #000000">&amp;</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0x0f</span>
						<span style="COLOR: #000000">] </span>
						<span style="COLOR: #000000">&lt;&lt;</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" /> }</span>
				</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
		</div>
<img src ="http://www.cppblog.com/snowball/aggbug/45985.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/snowball/" target="_blank">snowball</a> 2008-04-02 09:02 <a href="http://www.cppblog.com/snowball/archive/2008/04/02/45985.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>