typedef int SDataType;
typedef struct SeqStack
{
SDataType val[MAXSIZE];
int top;
}SeqStack;
void ListStackInit(ListStack* stack)
{
assert(stack);
stack->top = NULL;
stack->lenth = 0;
}
void ListStackPush(ListStack* stack, LDataType e)
{
StackNode* newnode = malloc(sizeof(StackNode));
assert(newnode);
newnode->val = e;
newnode->next = stack->top;
stack->top = newnode;
stack->lenth++;
}
bool ListStackEmpty(ListStack* stack)
{
return stack->top == NULL;
}
void ListStackPop(ListStack* stack)
{
if (!ListStackEmpty(stack))
{
perror("stack is empty\n");
return;
}
StackNode* del = stack->top;
stack->top = stack->top->next;
free(del);
}
LDataType ListStackTop(ListStack* stack)
{
assert(stack);
return stack->top->val;
}