Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define pb push_back
- #define MAX 500
- struct Stack{
- vector<int> p;
- bool isempty(){ return !p.size(); };
- bool isfull(){ return p.size() == MAX; };
- void push( int n ) {
- if( p.size() == MAX - 1 ) puts("Full!");
- else p.pb(n);
- };
- int pop(){
- if( !p.size() ) puts("Empty");
- else {
- int top = p[p.size() - 1];
- p.pop_back();
- return top;
- }
- }
- };
- int main(){
- Stack stk;
- stk.push(1);
- stk.push(2);
- stk.push(3);
- cout << stk.pop() <<endl;
- cout << stk.pop() <<endl;
- cout << stk.isempty() << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement