{"id":107,"date":"2005-06-29T20:15:30","date_gmt":"2005-06-29T12:15:30","guid":{"rendered":"http:\/\/yesybl.org\/blogcn\/2005\/06\/29\/107\/"},"modified":"2005-06-29T20:15:30","modified_gmt":"2005-06-29T12:15:30","slug":"thooaeeyieooaeeyuacidhouae-2","status":"publish","type":"post","link":"https:\/\/www.yesybl.com\/?p=107","title":{"rendered":"\u4e8c\u8fdb\u5236\u6570\u8f6c\u5316\u4e3a\u5341\u8fdb\u5236\u6570\u7684C\u7a0b\u5e8f\u4ee3\u7801\u3002"},"content":{"rendered":"<p>GCC\u4e0b\u6d4b\u8bd5\u901a\u8fc7\u3002<br \/>==========================================================================<br \/>#include&lt;stdlib.h&gt;<br \/>#include&lt;stdio.h&gt;<br \/>#include&lt;math.h&gt;<\/p>\n<p>main(int argc,char* argv[])<br \/>{<br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; int flag=0,divisor=1,count=0,i,power,Dec=0;<br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; long int InputBin;<br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; int Bin[20];<br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (argc != 2)<br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; {<br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; printf(&quot;Usage:btd number (Binrary number).n&quot;);<br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return 1;<br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; InputBin=atol(argv[1]);<br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; do<br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; {<\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; divisor=divisor*10;<br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; flag=InputBin\/divisor;<br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; count++;<br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; }while(flag);<br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; count&#8211;;<br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; for (i=0;i&lt;=count;i++)<br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; {<\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; divisor=divisor\/10;<br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (0==InputBin\/divisor ||1==InputBin\/divisor)<br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {<br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Bin[i]=InputBin\/divisor;<br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; InputBin=InputBin%divisor;<br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; else<br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {<br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; printf(&quot;Usage:btd number (Binrary number).n&quot;);<br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return 1;<br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; power=count;<br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; for (i=0;i&lt;=count;i++)<br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; {<br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Dec=Dec+Bin[i]*pow(2,power);<br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; power&#8211;;<br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; printf(&quot;The decimanl number is:%dn&quot;,Dec);<br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; return 0;<br \/>}<br \/>==================================================================================<\/p>\n","protected":false},"excerpt":{"rendered":"<a href=\"https:\/\/www.yesybl.com\/?p=107\" rel=\"bookmark\" title=\"Permalink to \u4e8c\u8fdb\u5236\u6570\u8f6c\u5316\u4e3a\u5341\u8fdb\u5236\u6570\u7684C\u7a0b\u5e8f\u4ee3\u7801\u3002\"><p>GCC\u4e0b\u6d4b\u8bd5\u901a\u8fc7\u3002==========================================================================#include&lt;stdlib.h&gt;#include&lt;stdio.h&gt;#include&lt;math.h&gt; main(int argc,char* argv[]){&#160;&#160;&#160;&#160;&#160;&#160;&#160; int flag=0,divisor=1,count=0,i,power,Dec=0;&#160;&#160;&#160;&#160;&#160;&#160;&#160; long int InputBin;&#160;&#160;&#160;&#160;&#160;&#160;&#160; int Bin[20];&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (argc != 2)&#160;&#160;&#160;&#160;&#160;&#160;&#160; {&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; printf(&quot;Usage:btd number (Binrary number).n&quot;);&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return 1;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }&#160;&#160;&#160;&#160;&#160;&#160;&#160; InputBin=atol(argv[1]);&#160;&#160;&#160;&#160;&#160;&#160;&#160; do&#160;&#160;&#160;&#160;&#160;&#160;&#160; { &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; divisor=divisor*10;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; flag=InputBin\/divisor;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; count++;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }while(flag);&#160;&#160;&#160;&#160;&#160;&#160;&#160; count&#8211;;&#160;&#160;&#160;&#160;&#160;&#160;&#160; for (i=0;i&lt;=count;i++)&#160;&#160;&#160;&#160;&#160;&#160;&#160; { &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; divisor=divisor\/10;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (0==InputBin\/divisor ||1==InputBin\/divisor)&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Bin[i]=InputBin\/divisor;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; InputBin=InputBin%divisor;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; else&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; printf(&quot;Usage:btd number (Binrary number).n&quot;);&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return 1;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }&#160;&#160;&#160;&#160;&#160;&#160;&#160; }&#160;&#160;&#160;&#160;&#160;&#160;&#160; power=count;&#160;&#160;&#160;&#160;&#160;&#160;&#160; [&hellip;]<\/p>\n<\/a>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pa4z28-1J","_links":{"self":[{"href":"https:\/\/www.yesybl.com\/index.php?rest_route=\/wp\/v2\/posts\/107"}],"collection":[{"href":"https:\/\/www.yesybl.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yesybl.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yesybl.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yesybl.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=107"}],"version-history":[{"count":0,"href":"https:\/\/www.yesybl.com\/index.php?rest_route=\/wp\/v2\/posts\/107\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.yesybl.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=107"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yesybl.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=107"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yesybl.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=107"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}