#include<stdio.h>
#include<malloc.h>
#include<stdlib.h>
typedef int SElemType;
typedef struct StackNode {
SElemType data;
struct StackNode* next;
}StackNode, * LinkStack;
/*
链栈的初始化
*/
void InitStack(LinkStack& S) {
S = NULL;
}
/*
判断链栈是否为空
*/
bool StackEmpty(LinkStack S) {
if (!S)
{
return true;
}
else {
return false;
}
}
/*
链栈的入栈
*/
int Push(LinkStack& S, SElemType e) {
LinkStack p = (LinkStack)malloc(sizeof(StackNode));
if (!p)exit(-1);
p->data = e;
p->next = S->next;
S->next = p;
return 1;
}
/*
链栈的出栈
*/
int Pop(LinkStack& S, SElemType& e) {
if (S == NULL) return -1;
e = S->data;
LinkStack p = S;
S = S->next;
free(p);
return 1;
}
int main() {
return 0;
}