typedef struct StackNode{
SElemType data;
struct StackNode *next;
}StackNode, *LinkStackPtr;
typdef struct LinkStack {
LinkStackPtr top;
int count;
}LinkStack;
bool Push(LinkStack *S, SElemType e)
{
LinkStackPtr s = (LinkStackPtr)malloc(sizeof(StackNode));
s->data = e;
s->next = S->top;
S->top = s;
S->count++;
return true;
}
bool Pop(LinkStack *S, SElemType *e)
{
LinkStackPtr p;
if(StackEmpty(*S))
{
return false;
}
*e = S->top->data;
p = S->top;
S->top = S->top->next;
free(p);
S->count--;
return true;
}
SElemType data;
struct StackNode *next;
}StackNode, *LinkStackPtr;
typdef struct LinkStack {
LinkStackPtr top;
int count;
}LinkStack;
bool Push(LinkStack *S, SElemType e)
{
LinkStackPtr s = (LinkStackPtr)malloc(sizeof(StackNode));
s->data = e;
s->next = S->top;
S->top = s;
S->count++;
return true;
}
bool Pop(LinkStack *S, SElemType *e)
{
LinkStackPtr p;
if(StackEmpty(*S))
{
return false;
}
*e = S->top->data;
p = S->top;
S->top = S->top->next;
free(p);
S->count--;
return true;
}