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; }