Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- #define dim 1001
- struct Stiva
- {
- int st[dim];
- int top;
- int Empty()
- {
- return top == -1;
- }
- int Full()
- {
- return top == dim-1;
- }
- void Init()
- {
- top = -1;
- }
- void Push(int x)
- {
- if (!Full())
- st[++top]=x;
- }
- void Pop()
- {
- if (!Empty()) top--;
- }
- int Front()
- {
- return st[top];
- }
- };
- int main()
- {
- int n;
- Stiva s;
- cout<<"n= ";
- cin>>n;
- s.Init();
- while(n>0)
- {
- s.Push(n%2);
- n/=2;
- }
- while(!s.Empty())
- {
- cout<<s.Front();
- s.Pop();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement