﻿<?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++博客-书山有路勤为径，学海无涯苦作舟</title><link>http://www.cppblog.com/wyjiuye/</link><description>生命不息，代码不止</description><language>zh-cn</language><lastBuildDate>Tue, 09 Jun 2026 17:42:46 GMT</lastBuildDate><pubDate>Tue, 09 Jun 2026 17:42:46 GMT</pubDate><ttl>60</ttl><item><title>二进制转十进制</title><link>http://www.cppblog.com/wyjiuye/archive/2012/03/10/167552.html</link><dc:creator>编码之美</dc:creator><author>编码之美</author><pubDate>Sat, 10 Mar 2012 06:10:00 GMT</pubDate><guid>http://www.cppblog.com/wyjiuye/archive/2012/03/10/167552.html</guid><wfw:comment>http://www.cppblog.com/wyjiuye/comments/167552.html</wfw:comment><comments>http://www.cppblog.com/wyjiuye/archive/2012/03/10/167552.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/wyjiuye/comments/commentRss/167552.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/wyjiuye/services/trackbacks/167552.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"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #008080">&nbsp;1</span><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top"  alt="" /><span style="color: #000000">#include&nbsp;</span><span style="color: #000000">&lt;</span><span style="color: #000000">stdio.h</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /></span><span style="color: #008080">&nbsp;2</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top"  alt="" /></span><span style="color: #0000ff">long</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;btd(</span><span style="color: #0000ff">char</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">s)&nbsp;<br /></span><span style="color: #008080">&nbsp;3</span><span style="color: #000000"><img id="Codehighlighter1_42_163_Open_Image" onclick="this.style.display='none'; Codehighlighter1_42_163_Open_Text.style.display='none'; Codehighlighter1_42_163_Closed_Image.style.display='inline'; Codehighlighter1_42_163_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top"><img id="Codehighlighter1_42_163_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_42_163_Closed_Text.style.display='none'; Codehighlighter1_42_163_Open_Image.style.display='inline'; Codehighlighter1_42_163_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top"></span><span id="Codehighlighter1_42_163_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"  alt="" /></span><span id="Codehighlighter1_42_163_Open_Text"><span style="color: #000000">{<br /></span><span style="color: #008080">&nbsp;4</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" />&nbsp;</span><span style="color: #0000ff">long</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;rt</span><span style="color: #000000">=</span><span style="color: #000000">0</span><span style="color: #000000">;<br /></span><span style="color: #008080">&nbsp;5</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" />&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;i,n</span><span style="color: #000000">=</span><span style="color: #000000">0</span><span style="color: #000000">;<br /></span><span style="color: #008080">&nbsp;6</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" />&nbsp;</span><span style="color: #0000ff">while</span><span style="color: #000000">&nbsp;(s[n])&nbsp;n</span><span style="color: #000000">++</span><span style="color: #000000">;<br /></span><span style="color: #008080">&nbsp;7</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" />&nbsp;</span><span style="color: #0000ff">for</span><span style="color: #000000">&nbsp;(</span><span style="color: #000000">--</span><span style="color: #000000">n,i</span><span style="color: #000000">=</span><span style="color: #000000">n;&nbsp;i</span><span style="color: #000000">&gt;=</span><span style="color: #000000">0</span><span style="color: #000000">;&nbsp;i</span><span style="color: #000000">--</span><span style="color: #000000">)<br /></span><span style="color: #008080">&nbsp;8</span><span style="color: #000000"><img id="Codehighlighter1_118_149_Open_Image" onclick="this.style.display='none'; Codehighlighter1_118_149_Open_Text.style.display='none'; Codehighlighter1_118_149_Closed_Image.style.display='inline'; Codehighlighter1_118_149_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_118_149_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_118_149_Closed_Text.style.display='none'; Codehighlighter1_118_149_Open_Image.style.display='inline'; Codehighlighter1_118_149_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top">&nbsp;</span><span id="Codehighlighter1_118_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"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_118_149_Open_Text"><span style="color: #000000">{&nbsp;&nbsp;&nbsp;&nbsp;<br /></span><span style="color: #008080">&nbsp;9</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;rt</span><span style="color: #000000">|=</span><span style="color: #000000">(s[i]</span><span style="color: #000000">-</span><span style="color: #000000">48</span><span style="color: #000000">)</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">n</span><span style="color: #000000">-</span><span style="color: #000000">i;<br /></span><span style="color: #008080">10</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"  alt="" />&nbsp;}</span></span><span style="color: #000000"><br /></span><span style="color: #008080">11</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" />&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;rt;<br /></span><span style="color: #008080">12</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top"  alt="" />}</span></span><span style="color: #000000"><br /></span><span style="color: #008080">13</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top"  alt="" /></span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;main(</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;argc,&nbsp;</span><span style="color: #0000ff">char</span><span style="color: #000000">*</span><span style="color: #000000">&nbsp;argv[])<br /></span><span style="color: #008080">14</span><span style="color: #000000"><img id="Codehighlighter1_198_240_Open_Image" onclick="this.style.display='none'; Codehighlighter1_198_240_Open_Text.style.display='none'; Codehighlighter1_198_240_Closed_Image.style.display='inline'; Codehighlighter1_198_240_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top"><img id="Codehighlighter1_198_240_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_198_240_Closed_Text.style.display='none'; Codehighlighter1_198_240_Open_Image.style.display='inline'; Codehighlighter1_198_240_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top"></span><span id="Codehighlighter1_198_240_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"  alt="" /></span><span id="Codehighlighter1_198_240_Open_Text"><span style="color: #000000">{<br /></span><span style="color: #008080">15</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" />&nbsp;printf(</span><span style="color: #000000">"</span><span style="color: #000000">%ld</span><span style="color: #000000">"</span><span style="color: #000000">,btd(</span><span style="color: #000000">"</span><span style="color: #000000">11011</span><span style="color: #000000">"</span><span style="color: #000000">));<br /></span><span style="color: #008080">16</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" />&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 /></span><span style="color: #008080">17</span><span style="color: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top"  alt="" />}</span></span></div><img src ="http://www.cppblog.com/wyjiuye/aggbug/167552.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/wyjiuye/" target="_blank">编码之美</a> 2012-03-10 14:10 <a href="http://www.cppblog.com/wyjiuye/archive/2012/03/10/167552.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>