1 2 3
1 10 11
二进制转化
#include<iostream> #include<algorithm> #include<cstdio> using namespace std; int main() { int ten,two,tmp; while(cin>>ten) { if(ten==1) { cout<<1<<endl; continue; } two=0,tmp=1; while(ten>1) { two+=(ten%2)*tmp; tmp*=10; ten=ten/2; if(ten==1) two+=ten*tmp; } cout<<two<<endl; } return 0; }