#include
using namespace std;
int main()
{
int a,b,c,d;
cout<<"请输入待转换的数:";
cin>>a;
//二进制分别计算每一位
if(a==0)cout< b=a;c=0;d=1;
while(b!=0)
{
c+=(b%2)*d;//依次把b除以2的余数写在c的对应位置上
b=b/2;
d*=10;
}
cout<
cout<
参考:http://zhidao.baidu.com/link?url=XR21eBWkgfEav2K6KBq_oXMrB7gjueN42HzP8Sl120BUVyiCxaSuWw0uT1bYFK2iE6C2opmZsSGlf-2i1nPfcq