12345678910111213141516171819202122232425262728293031323334353637383940414243444546
#include <iostream> #include <stdexcept> #include <string> using namespace std; #define STACK_SIZE 1000 int stc[STACK_SIZE]; int stack_pointer = STACK_SIZE - 1; int pop(){ if(stack_pointer < STACK_SIZE - 1){ int p = stc[stack_pointer]; stack_pointer++; return p; } else{ cout << endl <<"Error: Stack Overflow"<<endl; } return -1; } void push(int p){ if(stack_pointer > 0){ stack_pointer--; stc[stack_pointer]=p; } else{ cout<<endl<<"error: stack overflow"<<endl; } } int main(){ int a,b,c,A,B,C; a=1971; b=8; c=28; push(a); push(b); push(c); A = pop(); B = pop(); C = pop(); return 0; }