﻿<?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++博客-polaris-随笔分类-Algorithm</title><link>http://www.cppblog.com/polaris/category/3304.html</link><description /><language>zh-cn</language><lastBuildDate>Tue, 20 May 2008 11:09:17 GMT</lastBuildDate><pubDate>Tue, 20 May 2008 11:09:17 GMT</pubDate><ttl>60</ttl><item><title>最长对称子序列问题（Longest Symmetric Sequence）</title><link>http://www.cppblog.com/polaris/archive/2007/06/29/27232.html</link><dc:creator>哈胖头</dc:creator><author>哈胖头</author><pubDate>Fri, 29 Jun 2007 09:12:00 GMT</pubDate><guid>http://www.cppblog.com/polaris/archive/2007/06/29/27232.html</guid><wfw:comment>http://www.cppblog.com/polaris/comments/27232.html</wfw:comment><comments>http://www.cppblog.com/polaris/archive/2007/06/29/27232.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/polaris/comments/commentRss/27232.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/polaris/services/trackbacks/27232.html</trackback:ping><description><![CDATA[<img style="WIDTH: 575px; HEIGHT: 855px" height=855 alt="" src="http://www.cppblog.com/images/cppblog_com/polaris/lss.JPG" width=575 border=0> 
<img src ="http://www.cppblog.com/polaris/aggbug/27232.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/polaris/" target="_blank">哈胖头</a> 2007-06-29 17:12 <a href="http://www.cppblog.com/polaris/archive/2007/06/29/27232.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>泵引理（Pumping Lemma）</title><link>http://www.cppblog.com/polaris/archive/2007/06/28/27146.html</link><dc:creator>哈胖头</dc:creator><author>哈胖头</author><pubDate>Thu, 28 Jun 2007 07:58:00 GMT</pubDate><guid>http://www.cppblog.com/polaris/archive/2007/06/28/27146.html</guid><wfw:comment>http://www.cppblog.com/polaris/comments/27146.html</wfw:comment><comments>http://www.cppblog.com/polaris/archive/2007/06/28/27146.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/polaris/comments/commentRss/27146.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/polaris/services/trackbacks/27146.html</trackback:ping><description><![CDATA[<p><img height=768 alt="" src="http://www.cppblog.com/images/cppblog_com/polaris/pumping_lemma2.JPG" width=663 border=0></p>
<img src ="http://www.cppblog.com/polaris/aggbug/27146.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/polaris/" target="_blank">哈胖头</a> 2007-06-28 15:58 <a href="http://www.cppblog.com/polaris/archive/2007/06/28/27146.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>通配符匹配算法</title><link>http://www.cppblog.com/polaris/archive/2007/06/28/27144.html</link><dc:creator>哈胖头</dc:creator><author>哈胖头</author><pubDate>Thu, 28 Jun 2007 07:37:00 GMT</pubDate><guid>http://www.cppblog.com/polaris/archive/2007/06/28/27144.html</guid><wfw:comment>http://www.cppblog.com/polaris/comments/27144.html</wfw:comment><comments>http://www.cppblog.com/polaris/archive/2007/06/28/27144.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/polaris/comments/commentRss/27144.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/polaris/services/trackbacks/27144.html</trackback:ping><description><![CDATA[<p>通配符匹配属于正则表达式匹配的一种特殊情况，它包含两种通配字符：*和?。</p>
<p>其中通配符 * 表示可以匹配0个或多个任意的字符；</p>
<p>其中通配符 ? 表示可以匹配0个或1个任意字符。</p>
<p>如果不想对通配的模式进行预处理，可以使用如下递归的wildcard匹配，只不过这种匹配方式比较低效。其实，位并行算法(bit-parallel)算法是处理通配符匹配的一种有效技术，我们将另文介绍。</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 id=Codehighlighter1_0_149_Open_Image onclick="this.style.display='none'; Codehighlighter1_0_149_Open_Text.style.display='none'; Codehighlighter1_0_149_Closed_Image.style.display='inline'; Codehighlighter1_0_149_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_0_149_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_0_149_Closed_Text.style.display='none'; Codehighlighter1_0_149_Open_Image.style.display='inline'; Codehighlighter1_0_149_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif" align=top><span id=Codehighlighter1_0_149_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_149_Open_Text><span style="COLOR: #008000">/*</span><span style="COLOR: #008000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>recursive&nbsp;wildcard&nbsp;matching&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>*&nbsp;:&nbsp;match&nbsp;zero&nbsp;or&nbsp;more&nbsp;characters;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>?&nbsp;:&nbsp;match&nbsp;zero&nbsp;or&nbsp;one&nbsp;character.<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>return&nbsp;value:<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>1&nbsp;:&nbsp;match&nbsp;success.<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>0&nbsp;:&nbsp;no&nbsp;match.<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top></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">int</span><span style="COLOR: #000000">&nbsp;wildcard(</span><span style="COLOR: #0000ff">const</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">&nbsp;pat,&nbsp;</span><span style="COLOR: #0000ff">const</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">&nbsp;str)<br><img id=Codehighlighter1_200_649_Open_Image onclick="this.style.display='none'; Codehighlighter1_200_649_Open_Text.style.display='none'; Codehighlighter1_200_649_Closed_Image.style.display='inline'; Codehighlighter1_200_649_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_200_649_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_200_649_Closed_Text.style.display='none'; Codehighlighter1_200_649_Open_Image.style.display='inline'; Codehighlighter1_200_649_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=Codehighlighter1_200_649_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_649_Open_Text><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">str&nbsp;</span><span style="COLOR: #000000">&amp;&amp;</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">pat)&nbsp;<br><img id=Codehighlighter1_223_572_Open_Image onclick="this.style.display='none'; Codehighlighter1_223_572_Open_Text.style.display='none'; Codehighlighter1_223_572_Closed_Image.style.display='inline'; Codehighlighter1_223_572_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_223_572_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_223_572_Closed_Text.style.display='none'; Codehighlighter1_223_572_Open_Image.style.display='inline'; Codehighlighter1_223_572_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top></span><span id=Codehighlighter1_223_572_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_223_572_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">pat</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 id=Codehighlighter1_245_311_Open_Image onclick="this.style.display='none'; Codehighlighter1_245_311_Open_Text.style.display='none'; Codehighlighter1_245_311_Closed_Image.style.display='inline'; Codehighlighter1_245_311_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_245_311_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_245_311_Closed_Text.style.display='none'; Codehighlighter1_245_311_Open_Image.style.display='inline'; Codehighlighter1_245_311_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;</span><span id=Codehighlighter1_245_311_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_245_311_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(wildcard(pat</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">,&nbsp;str))&nbsp;</span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;str</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;pat</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;}</span></span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">pat</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 id=Codehighlighter1_338_501_Open_Image onclick="this.style.display='none'; Codehighlighter1_338_501_Open_Text.style.display='none'; Codehighlighter1_338_501_Closed_Image.style.display='inline'; Codehighlighter1_338_501_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_338_501_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_338_501_Closed_Text.style.display='none'; Codehighlighter1_338_501_Open_Image.style.display='inline'; Codehighlighter1_338_501_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;</span><span id=Codehighlighter1_338_501_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_338_501_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">(</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">pat</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">&nbsp;</span><span style="COLOR: #000000">||</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">pat</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">)&nbsp;pat</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(</span><span style="COLOR: #000000">!*</span><span style="COLOR: #000000">pat)&nbsp;</span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">1</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>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">(</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">str)<br><img id=Codehighlighter1_426_482_Open_Image onclick="this.style.display='none'; Codehighlighter1_426_482_Open_Text.style.display='none'; Codehighlighter1_426_482_Closed_Image.style.display='inline'; Codehighlighter1_426_482_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_426_482_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_426_482_Closed_Text.style.display='none'; Codehighlighter1_426_482_Open_Image.style.display='inline'; Codehighlighter1_426_482_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span id=Codehighlighter1_426_482_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_426_482_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(wildcard(pat,&nbsp;str))&nbsp;</span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;str</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;}</span></span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"><br><img id=Codehighlighter1_514_570_Open_Image onclick="this.style.display='none'; Codehighlighter1_514_570_Open_Text.style.display='none'; Codehighlighter1_514_570_Closed_Image.style.display='inline'; Codehighlighter1_514_570_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_514_570_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_514_570_Closed_Text.style.display='none'; Codehighlighter1_514_570_Open_Image.style.display='inline'; Codehighlighter1_514_570_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;</span><span id=Codehighlighter1_514_570_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_514_570_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">pat</span><span style="COLOR: #000000">!=*</span><span style="COLOR: #000000">str)&nbsp;</span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;str</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;pat</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;}</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><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">str</span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">)&nbsp;</span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">0</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">while</span><span style="COLOR: #000000">(</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">pat</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">&nbsp;</span><span style="COLOR: #000000">||</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">pat</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">)&nbsp;pat</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">return</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">!*</span><span style="COLOR: #000000">pat;<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/polaris/aggbug/27144.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/polaris/" target="_blank">哈胖头</a> 2007-06-28 15:37 <a href="http://www.cppblog.com/polaris/archive/2007/06/28/27144.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>计算最大公约数和最小公倍数的方法</title><link>http://www.cppblog.com/polaris/archive/2007/01/02/17152.html</link><dc:creator>哈胖头</dc:creator><author>哈胖头</author><pubDate>Tue, 02 Jan 2007 11:34:00 GMT</pubDate><guid>http://www.cppblog.com/polaris/archive/2007/01/02/17152.html</guid><wfw:comment>http://www.cppblog.com/polaris/comments/17152.html</wfw:comment><comments>http://www.cppblog.com/polaris/archive/2007/01/02/17152.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/polaris/comments/commentRss/17152.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/polaris/services/trackbacks/17152.html</trackback:ping><description><![CDATA[<p>在编程中，经常需要计算最大公约数和最小公倍数。本文介绍计算他们的方法。<br>在数论中，两个数a和b的最大公约数记为gcd(a, b)，最小公倍数记为lcm(a, b)。</p>
<p>计算最大公约数的算法是Euclid算法，即所谓的&#8220;辗转相除法&#8221;：</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">&nbsp;gcd(&nbsp;</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;a,&nbsp;</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;b)<br><img id=Codehighlighter1_23_63_Open_Image onclick="this.style.display='none'; Codehighlighter1_23_63_Open_Text.style.display='none'; Codehighlighter1_23_63_Closed_Image.style.display='inline'; Codehighlighter1_23_63_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_23_63_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_23_63_Closed_Text.style.display='none'; Codehighlighter1_23_63_Open_Image.style.display='inline'; Codehighlighter1_23_63_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=Codehighlighter1_23_63_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_63_Open_Text><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">&nbsp;(b&nbsp;</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">&nbsp;)&nbsp;</span><span style="COLOR: #000000">?</span><span style="COLOR: #000000">&nbsp;a&nbsp;:&nbsp;gcd(b,&nbsp;a&nbsp;</span><span style="COLOR: #000000">%</span><span style="COLOR: #000000">&nbsp;b);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000">&nbsp;</span></div>
<p><br>该算法的时间复杂度为O(log(max(a, b)))，因而是相当快的。</p>
<p>根据初等数论的知识：对于任意的a和b，gcd(a, b) * lcm(a, b)=a*b。据此很容易得到计算最小公倍数的方法：</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">&nbsp;lcm(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;a,&nbsp;</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;b)<br><img id=Codehighlighter1_22_48_Open_Image onclick="this.style.display='none'; Codehighlighter1_22_48_Open_Text.style.display='none'; Codehighlighter1_22_48_Closed_Image.style.display='inline'; Codehighlighter1_22_48_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_22_48_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_22_48_Closed_Text.style.display='none'; Codehighlighter1_22_48_Open_Image.style.display='inline'; Codehighlighter1_22_48_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=Codehighlighter1_22_48_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_22_48_Open_Text><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">&nbsp;(a</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">b)</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">gcd(a,&nbsp;b);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span></div>
<p>&nbsp;</p>
<p>另外一个计算lcm的方法来自newsmth的programming版，它只用加减法即可完成计算： </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">&nbsp;LCM(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;a,&nbsp;</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;b)<br><img id=Codehighlighter1_22_186_Open_Image onclick="this.style.display='none'; Codehighlighter1_22_186_Open_Text.style.display='none'; Codehighlighter1_22_186_Closed_Image.style.display='inline'; Codehighlighter1_22_186_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_22_186_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_22_186_Closed_Text.style.display='none'; Codehighlighter1_22_186_Open_Image.style.display='inline'; Codehighlighter1_22_186_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=Codehighlighter1_22_186_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_22_186_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">&nbsp;x</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">a,&nbsp;y</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">b;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;u</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">b,&nbsp;v</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">a;<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">while</span><span style="COLOR: #000000">(x</span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000">y)<br><img id=Codehighlighter1_65_167_Open_Image onclick="this.style.display='none'; Codehighlighter1_65_167_Open_Text.style.display='none'; Codehighlighter1_65_167_Closed_Image.style.display='inline'; Codehighlighter1_65_167_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_65_167_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_65_167_Closed_Text.style.display='none'; Codehighlighter1_65_167_Open_Image.style.display='inline'; Codehighlighter1_65_167_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top></span><span id=Codehighlighter1_65_167_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_65_167_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(x</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">y)<br><img id=Codehighlighter1_85_116_Open_Image onclick="this.style.display='none'; Codehighlighter1_85_116_Open_Text.style.display='none'; Codehighlighter1_85_116_Closed_Image.style.display='inline'; Codehighlighter1_85_116_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_85_116_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_85_116_Closed_Text.style.display='none'; Codehighlighter1_85_116_Open_Image.style.display='inline'; Codehighlighter1_85_116_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id=Codehighlighter1_85_116_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_85_116_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;x</span><span style="COLOR: #000000">-=</span><span style="COLOR: #000000">y;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;v</span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000">u;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"><br><img id=Codehighlighter1_133_165_Open_Image onclick="this.style.display='none'; Codehighlighter1_133_165_Open_Text.style.display='none'; Codehighlighter1_133_165_Closed_Image.style.display='inline'; Codehighlighter1_133_165_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_133_165_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_133_165_Closed_Text.style.display='none'; Codehighlighter1_133_165_Open_Image.style.display='inline'; Codehighlighter1_133_165_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id=Codehighlighter1_133_165_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_133_165_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;y</span><span style="COLOR: #000000">-=</span><span style="COLOR: #000000">x;&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;u</span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000">v;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</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><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000">&nbsp;(u</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">v)</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><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/polaris/aggbug/17152.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/polaris/" target="_blank">哈胖头</a> 2007-01-02 19:34 <a href="http://www.cppblog.com/polaris/archive/2007/01/02/17152.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>TopCoder-srm-283-II-3</title><link>http://www.cppblog.com/polaris/archive/2006/12/27/16917.html</link><dc:creator>哈胖头</dc:creator><author>哈胖头</author><pubDate>Wed, 27 Dec 2006 12:57:00 GMT</pubDate><guid>http://www.cppblog.com/polaris/archive/2006/12/27/16917.html</guid><wfw:comment>http://www.cppblog.com/polaris/comments/16917.html</wfw:comment><comments>http://www.cppblog.com/polaris/archive/2006/12/27/16917.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/polaris/comments/commentRss/16917.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/polaris/services/trackbacks/16917.html</trackback:ping><description><![CDATA[
		<p>
				<br />Problem Statement <br />The greatest common divisor (GCD) of two positive integers a and b is the largest integer that evenly divides both a and b. In this problem, you will find the GCD of a positive integer and the factorial of a non-negative integer. </p>
		<p>Create a class FactorialGCD with method factGCD which takes an int a and an int b as parameters and returns the GCD of a! (the factorial of a) and b. <br /></p>
		<p> </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">utility</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">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" />
				</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">class</span>
				<span style="COLOR: #000000"> FactorialGCD<br /><img id="Codehighlighter1_80_424_Open_Image" onclick="this.style.display='none'; Codehighlighter1_80_424_Open_Text.style.display='none'; Codehighlighter1_80_424_Closed_Image.style.display='inline'; Codehighlighter1_80_424_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_80_424_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_80_424_Closed_Text.style.display='none'; Codehighlighter1_80_424_Open_Image.style.display='inline'; Codehighlighter1_80_424_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_80_424_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_80_424_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /></span>
						<span style="COLOR: #0000ff">public</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"> factGCD(</span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> a, </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> b) <br /><img id="Codehighlighter1_119_422_Open_Image" onclick="this.style.display='none'; Codehighlighter1_119_422_Open_Text.style.display='none'; Codehighlighter1_119_422_Closed_Image.style.display='inline'; Codehighlighter1_119_422_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_119_422_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_119_422_Closed_Text.style.display='none'; Codehighlighter1_119_422_Open_Image.style.display='inline'; Codehighlighter1_119_422_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" /> </span>
						<span id="Codehighlighter1_119_422_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_119_422_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />  unsigned </span>
								<span style="COLOR: #0000ff">int</span>
								<span style="COLOR: #000000"> gcd</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" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />  </span>
								<span style="COLOR: #0000ff">while</span>
								<span style="COLOR: #000000">(b</span>
								<span style="COLOR: #000000">&gt;</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_159_404_Open_Image" onclick="this.style.display='none'; Codehighlighter1_159_404_Open_Text.style.display='none'; Codehighlighter1_159_404_Closed_Image.style.display='inline'; Codehighlighter1_159_404_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_159_404_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_159_404_Closed_Text.style.display='none'; Codehighlighter1_159_404_Open_Image.style.display='inline'; Codehighlighter1_159_404_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />  </span>
								<span id="Codehighlighter1_159_404_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_159_404_Open_Text">
										<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />   unsigned </span>
										<span style="COLOR: #0000ff">int</span>
										<span style="COLOR: #000000"> p;<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">(p</span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000">2</span>
										<span style="COLOR: #000000">; p</span>
										<span style="COLOR: #000000">*</span>
										<span style="COLOR: #000000">p</span>
										<span style="COLOR: #000000">&lt;=</span>
										<span style="COLOR: #000000">(unsigned </span>
										<span style="COLOR: #0000ff">int</span>
										<span style="COLOR: #000000">)b </span>
										<span style="COLOR: #000000">&amp;&amp;</span>
										<span style="COLOR: #000000"> b</span>
										<span style="COLOR: #000000">%</span>
										<span style="COLOR: #000000">p</span>
										<span style="COLOR: #000000">!=</span>
										<span style="COLOR: #000000">0</span>
										<span style="COLOR: #000000">; p</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">if</span>
										<span style="COLOR: #000000">(b</span>
										<span style="COLOR: #000000">%</span>
										<span style="COLOR: #000000">p</span>
										<span style="COLOR: #000000">!=</span>
										<span style="COLOR: #000000">0</span>
										<span style="COLOR: #000000">) p</span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000">b;<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">int</span>
										<span style="COLOR: #000000"> n</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">( ; b</span>
										<span style="COLOR: #000000">%</span>
										<span style="COLOR: #000000">p</span>
										<span style="COLOR: #000000">==</span>
										<span style="COLOR: #000000">0</span>
										<span style="COLOR: #000000">; b</span>
										<span style="COLOR: #000000">/=</span>
										<span style="COLOR: #000000">p) n</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">int</span>
										<span style="COLOR: #000000"> m</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">(unsigned </span>
										<span style="COLOR: #0000ff">int</span>
										<span style="COLOR: #000000"> j</span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000">a; j</span>
										<span style="COLOR: #000000">&gt;=</span>
										<span style="COLOR: #000000">p; ) m</span>
										<span style="COLOR: #000000">+=</span>
										<span style="COLOR: #000000">(j</span>
										<span style="COLOR: #000000">/=</span>
										<span style="COLOR: #000000">p);<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">(</span>
										<span style="COLOR: #0000ff">int</span>
										<span style="COLOR: #000000"> i</span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000">0</span>
										<span style="COLOR: #000000">; i</span>
										<span style="COLOR: #000000">&lt;</span>
										<span style="COLOR: #000000">min(n, m); i</span>
										<span style="COLOR: #000000">++</span>
										<span style="COLOR: #000000">) gcd</span>
										<span style="COLOR: #000000">*=</span>
										<span style="COLOR: #000000">p;<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" />
										<br />
										<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />  </span>
								<span style="COLOR: #0000ff">return</span>
								<span style="COLOR: #000000"> gcd;<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/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_439_732_Open_Image" onclick="this.style.display='none'; Codehighlighter1_439_732_Open_Text.style.display='none'; Codehighlighter1_439_732_Closed_Image.style.display='inline'; Codehighlighter1_439_732_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_439_732_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_439_732_Closed_Text.style.display='none'; Codehighlighter1_439_732_Open_Image.style.display='inline'; Codehighlighter1_439_732_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_439_732_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_732_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /> FactorialGCD test;<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" /> cout </span>
						<span style="COLOR: #000000">&lt;&lt;</span>
						<span style="COLOR: #000000"> test.factGCD(</span>
						<span style="COLOR: #000000">5</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #000000">20</span>
						<span style="COLOR: #000000">) </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" /><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"> test.factGCD(</span>
						<span style="COLOR: #000000">7</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #000000">5040</span>
						<span style="COLOR: #000000">) </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" /><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"> test.factGCD(</span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #000000">2425</span>
						<span style="COLOR: #000000">) </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" /><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"> test.factGCD(</span>
						<span style="COLOR: #000000">667024</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">) </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" /><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"> test.factGCD(</span>
						<span style="COLOR: #000000">4</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #000000">40</span>
						<span style="COLOR: #000000">) </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" /><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"> test.factGCD(</span>
						<span style="COLOR: #000000">2097711064</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #000000">2147483646</span>
						<span style="COLOR: #000000">) </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" /><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/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>
<img src ="http://www.cppblog.com/polaris/aggbug/16917.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/polaris/" target="_blank">哈胖头</a> 2006-12-27 20:57 <a href="http://www.cppblog.com/polaris/archive/2006/12/27/16917.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>进制转换</title><link>http://www.cppblog.com/polaris/archive/2006/12/22/16754.html</link><dc:creator>哈胖头</dc:creator><author>哈胖头</author><pubDate>Fri, 22 Dec 2006 12:07:00 GMT</pubDate><guid>http://www.cppblog.com/polaris/archive/2006/12/22/16754.html</guid><wfw:comment>http://www.cppblog.com/polaris/comments/16754.html</wfw:comment><comments>http://www.cppblog.com/polaris/archive/2006/12/22/16754.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/polaris/comments/commentRss/16754.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/polaris/services/trackbacks/16754.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">
						<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" />
				</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" />#include </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #0000ff">string</span>
				<span style="COLOR: #000000">.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">void</span>
				<span style="COLOR: #000000"> BaseConv1(</span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000"> s, </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> a, </span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000"> t, </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> b)<br /><img id="Codehighlighter1_112_426_Open_Image" onclick="this.style.display='none'; Codehighlighter1_112_426_Open_Text.style.display='none'; Codehighlighter1_112_426_Closed_Image.style.display='inline'; Codehighlighter1_112_426_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_112_426_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_112_426_Closed_Text.style.display='none'; Codehighlighter1_112_426_Open_Image.style.display='inline'; Codehighlighter1_112_426_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_112_426_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_112_426_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"> q</span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000">t;<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">while</span>
						<span style="COLOR: #000000">(</span>
						<span style="COLOR: #000000">*</span>
						<span style="COLOR: #000000">s)<br /><img id="Codehighlighter1_146_327_Open_Image" onclick="this.style.display='none'; Codehighlighter1_146_327_Open_Text.style.display='none'; Codehighlighter1_146_327_Closed_Image.style.display='inline'; Codehighlighter1_146_327_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_146_327_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_146_327_Closed_Text.style.display='none'; Codehighlighter1_146_327_Open_Image.style.display='inline'; Codehighlighter1_146_327_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_146_327_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_146_327_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"> r</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" /><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">char</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">s; </span>
								<span style="COLOR: #000000">*</span>
								<span style="COLOR: #000000">p; p</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_201_261_Open_Image" onclick="this.style.display='none'; Codehighlighter1_201_261_Open_Text.style.display='none'; Codehighlighter1_201_261_Closed_Image.style.display='inline'; Codehighlighter1_201_261_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_201_261_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_201_261_Closed_Text.style.display='none'; Codehighlighter1_201_261_Open_Image.style.display='inline'; Codehighlighter1_201_261_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
								<span id="Codehighlighter1_201_261_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_201_261_Open_Text">
										<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            r</span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000">a</span>
										<span style="COLOR: #000000">*</span>
										<span style="COLOR: #000000">r</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">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: #000000">*</span>
										<span style="COLOR: #000000">p</span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000">r</span>
										<span style="COLOR: #000000">/</span>
										<span style="COLOR: #000000">b</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" />            r</span>
										<span style="COLOR: #000000">%=</span>
										<span style="COLOR: #000000">b;<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" />        <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #000000">*</span>
								<span style="COLOR: #000000">q</span>
								<span style="COLOR: #000000">++=</span>
								<span style="COLOR: #000000">r</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" /><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">s</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">) s</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" />    <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #000000">*</span>
						<span style="COLOR: #000000">q</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" /><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">char</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">*</span>
						<span style="COLOR: #000000"> u</span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000">t, </span>
						<span style="COLOR: #000000">*</span>
						<span style="COLOR: #000000"> v</span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000">q</span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">; u</span>
						<span style="COLOR: #000000">&lt;</span>
						<span style="COLOR: #000000">v; u</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">, v</span>
						<span style="COLOR: #000000">--</span>
						<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_391_424_Open_Image" onclick="this.style.display='none'; Codehighlighter1_391_424_Open_Text.style.display='none'; Codehighlighter1_391_424_Closed_Image.style.display='inline'; Codehighlighter1_391_424_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_391_424_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_391_424_Closed_Text.style.display='none'; Codehighlighter1_391_424_Open_Image.style.display='inline'; Codehighlighter1_391_424_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_391_424_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_391_424_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"> c</span>
								<span style="COLOR: #000000">=*</span>
								<span style="COLOR: #000000">u;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #000000">*</span>
								<span style="COLOR: #000000">u</span>
								<span style="COLOR: #000000">=*</span>
								<span style="COLOR: #000000">v;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #000000">*</span>
								<span style="COLOR: #000000">v</span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000">c;<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/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">void</span>
				<span style="COLOR: #000000"> BaseConv2(</span>
				<span style="COLOR: #0000ff">const</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000"> s, </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> a, </span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000"> t, </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> b)<br /><img id="Codehighlighter1_484_791_Open_Image" onclick="this.style.display='none'; Codehighlighter1_484_791_Open_Text.style.display='none'; Codehighlighter1_484_791_Closed_Image.style.display='inline'; Codehighlighter1_484_791_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_484_791_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_484_791_Closed_Text.style.display='none'; Codehighlighter1_484_791_Open_Image.style.display='inline'; Codehighlighter1_484_791_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_484_791_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_791_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">=</span>
						<span style="COLOR: #000000">t;<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">(</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">\0</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">; </span>
						<span style="COLOR: #000000">*</span>
						<span style="COLOR: #000000">s; s</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_531_684_Open_Image" onclick="this.style.display='none'; Codehighlighter1_531_684_Open_Text.style.display='none'; Codehighlighter1_531_684_Closed_Image.style.display='inline'; Codehighlighter1_531_684_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_531_684_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_531_684_Closed_Text.style.display='none'; Codehighlighter1_531_684_Open_Image.style.display='inline'; Codehighlighter1_531_684_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_531_684_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_531_684_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">s</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" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">for</span>
								<span style="COLOR: #000000">(p</span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000">t; </span>
								<span style="COLOR: #000000">*</span>
								<span style="COLOR: #000000">p; p</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_572_619_Open_Image" onclick="this.style.display='none'; Codehighlighter1_572_619_Open_Text.style.display='none'; Codehighlighter1_572_619_Closed_Image.style.display='inline'; Codehighlighter1_572_619_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_572_619_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_572_619_Closed_Text.style.display='none'; Codehighlighter1_572_619_Open_Image.style.display='inline'; Codehighlighter1_572_619_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
								<span id="Codehighlighter1_572_619_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_572_619_Open_Text">
										<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">a</span>
										<span style="COLOR: #000000">*</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">0</span>
										<span style="COLOR: #000000">'</span>
										<span style="COLOR: #000000">)</span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000">x;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #000000">*</span>
										<span style="COLOR: #000000">p</span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000">x</span>
										<span style="COLOR: #000000">%</span>
										<span style="COLOR: #000000">b</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" />            x</span>
										<span style="COLOR: #000000">/=</span>
										<span style="COLOR: #000000">b;<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" />
										<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_635_665_Open_Image" onclick="this.style.display='none'; Codehighlighter1_635_665_Open_Text.style.display='none'; Codehighlighter1_635_665_Closed_Image.style.display='inline'; Codehighlighter1_635_665_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_635_665_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_635_665_Closed_Text.style.display='none'; Codehighlighter1_635_665_Open_Image.style.display='inline'; Codehighlighter1_635_665_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
								<span id="Codehighlighter1_635_665_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_635_665_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">p</span>
										<span style="COLOR: #000000">++=</span>
										<span style="COLOR: #000000">x</span>
										<span style="COLOR: #000000">%</span>
										<span style="COLOR: #000000">b</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" />            x</span>
										<span style="COLOR: #000000">/=</span>
										<span style="COLOR: #000000">b;<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" />
										<br />
										<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </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">\0</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" />
								<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">char</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">*</span>
						<span style="COLOR: #000000"> u</span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000">t, </span>
						<span style="COLOR: #000000">*</span>
						<span style="COLOR: #000000"> v</span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000">p</span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">; u</span>
						<span style="COLOR: #000000">&lt;</span>
						<span style="COLOR: #000000">v; u</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">, v</span>
						<span style="COLOR: #000000">--</span>
						<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_735_789_Open_Image" onclick="this.style.display='none'; Codehighlighter1_735_789_Open_Text.style.display='none'; Codehighlighter1_735_789_Closed_Image.style.display='inline'; Codehighlighter1_735_789_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_735_789_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_735_789_Closed_Text.style.display='none'; Codehighlighter1_735_789_Open_Image.style.display='inline'; Codehighlighter1_735_789_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_735_789_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_735_789_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"> c</span>
								<span style="COLOR: #000000">=*</span>
								<span style="COLOR: #000000">u;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #000000">*</span>
								<span style="COLOR: #000000">u</span>
								<span style="COLOR: #000000">=*</span>
								<span style="COLOR: #000000">v;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #000000">*</span>
								<span style="COLOR: #000000">v</span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000">c;<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/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_805_1090_Open_Image" onclick="this.style.display='none'; Codehighlighter1_805_1090_Open_Text.style.display='none'; Codehighlighter1_805_1090_Closed_Image.style.display='inline'; Codehighlighter1_805_1090_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_805_1090_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_805_1090_Closed_Text.style.display='none'; Codehighlighter1_805_1090_Open_Image.style.display='inline'; Codehighlighter1_805_1090_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_805_1090_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_805_1090_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"> s[]</span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">987654321014612555422121454541212229852142104542345678901</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">char</span>
						<span style="COLOR: #000000"> t[</span>
						<span style="COLOR: #000000">4096</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" />    cout </span>
						<span style="COLOR: #000000">&lt;&lt;</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">s=</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">&lt;&lt;</span>
						<span style="COLOR: #000000"> s </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" />    BaseConv2(s, </span>
						<span style="COLOR: #000000">10</span>
						<span style="COLOR: #000000">, t, </span>
						<span style="COLOR: #000000">8</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">"</span>
						<span style="COLOR: #000000">t=</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">&lt;&lt;</span>
						<span style="COLOR: #000000"> t </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" /><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">"</span>
						<span style="COLOR: #000000">s=</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">&lt;&lt;</span>
						<span style="COLOR: #000000"> s </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" />    BaseConv1(s, </span>
						<span style="COLOR: #000000">10</span>
						<span style="COLOR: #000000">, t, </span>
						<span style="COLOR: #000000">8</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">"</span>
						<span style="COLOR: #000000">t=</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">&lt;&lt;</span>
						<span style="COLOR: #000000"> t </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" /><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/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/polaris/aggbug/16754.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/polaris/" target="_blank">哈胖头</a> 2006-12-22 20:07 <a href="http://www.cppblog.com/polaris/archive/2006/12/22/16754.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>