Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int *s;
- int head=0;
- void push (int x){
- head++;
- s[head]=x;
- }
- int pop(){
- head--;
- return s[head+1];
- }
- int peek(){
- return s[head];
- }
- int main()
- {
- s = new int[1000];
- s[0]=0;
- push(1);
- push(2);
- push(3);
- cout<<pop()<<endl;
- cout<<pop()<<endl;
- cout<<pop()<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement