Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- struct Stack
- {
- int Array[100];
- int Top;
- Stack()
- {
- Top = -1;
- for(int i=0; i<100; i++) Array[i] = 0;
- }
- void push(int val)
- {
- Top++;
- Array[Top] = val;
- }
- int top()
- {
- if(Top == -1) return 0;
- return Array[Top];
- }
- void pop()
- {
- if(Top == -1) return;
- Top--;
- }
- bool Empty()
- {
- if(Top == -1) return true;
- else return false;
- }
- int Size()
- {
- return Top+1;
- }
- };
- int main()
- {
- Stack st, binti;
- for(int i=1; i<=5; i++)
- {
- st.push(i);
- }
- /// 1 2 3 4 5
- for(int i=26; i<=30; i++)
- {
- binti.push(i);
- }
- ///26 27 28 29 30
- for(int i=1; i<=5; i++)
- {
- printf("top of st = %d\n",st.top());
- st.pop();
- printf("top of binti = %d\n", binti.top());
- binti.pop();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement