/*栈的链接存储结构及实现*/
//初始化栈
void InitStack(Node *top)
{
top = NULL;
}
//入栈操作
void Push(Node *top,DataType x)
{
s = (Node)malloc(sizeof(Node));
s->data = s;
s->next = top;
top = s;
}
//出栈操作
DataType Pop(Node *top)
{
if(top == NULL)
{
printf(“下溢”);
exit(-1);
}
x = top->data;
p = top;
top = top->next;
free(p);
return x;
}
//取栈顶元素
DataType GetTop(Node *top)
{
if(top = NULL)
{
printf(“下溢”);
exit(-1);
}
return top->data;
}
//空栈操作
int Empty(Node *top)
{
if(top == NULL)
return 1;
else
return 0;
}