1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
void push(int x) { StackNode *tmp=new StackNode; tmp->data=x; tmp->next=top; top=tmp; } /*The method pop which return the element poped out of the stack*/ int pop() { int v; StackNode *q; if(top!=NULL) { q=top; v=top->data; top=top->next; delete(q); return v; } else return -1; } |