除二取余法:余数进栈,最后从栈顶依次输出(逆序输出)
#include<iostream>
#include<stack>
using namespace std;
stack<int>bin;
int main(){
int t;
while(scanf("%d",&t)!=EOF){
if(t==0)printf("0");
while(t!=0){
bin.push(t%2);
t=t/2;
}
while(bin.size()!=0){
printf("%d",bin.top());
bin.pop();
}
printf("\n");
}
return 0;
}