Give you a number on base ten,you should output it on base two.(0 < n < 1000)
1 2 3
1 10 11
/*题意将一个10进制数n按照二进制书输出出来
思路:直接加入栈当n == 1时跳出并输出即可*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <stack>
using namespace std;
int main()
{
int n;
while(scanf("%d", &n) != EOF){
stack <int >q;
while(1){
int a;
a = n % 2;
q.push(a);
if(n == 1) break;
n /= 2;
}
while(!q.empty()){
printf("%d", q.top());
q.pop();
}
printf("\n");
}
return 0;
}