include [HTML_REMOVED]
using namespace std;
//顺序栈的定义
int stk[N] ,top = -1;
//链栈的定义
struct Node{
int val;
Node *next;
}
//初始化头节点
Node init(){
Node dummy = new Node(-1);
return dummy;
}
//判断栈空
bool empty(Node *dummy){
return dummy->next == NULL;
}
//进栈(头插法)
void push(Node dummy,int x){
Node node = new Node(x);
node->next = dummy->next;
dummy->next = node;
}
//出栈
void pop(Node *dummy){
dummy->next = dummy->next->next;
}
//读取栈顶元素
int top(Node *dummy){
return dummy->next->val;
}