1 #include<iostream>
2 using namespace std;
3 class Stack
4 {
5 private:
6 int stack[32];//int 类型占4字节
7 int top;//栈顶指针
8 public:
9 Stack()
10 {
11 top = 0;
12 }
13 void push(int n)//入栈
14 {
15 stack[top++] = n;
16 }
17 int pop()//出栈,返回栈顶元素
18 {
19 return stack[--top];
20 }
21 int getTop()//返回栈顶索引
22 {
23 return top;
24 }
25 } ;
26
27 int main()
28 {
29 int n;
30 Stack s;
31 while(cin>>n&&n>0)
32 {
33 while(n)//依次入栈
34 {
35 s.push(n%2);
36 n/=2;
37 }
38 while(s.getTop()!=0)//依次出栈
39 {
40 cout<<s.pop();
41 }
42 cout<<endl;
43 }
44 return 0;
45 }