求帮忙改错!拜托.....
# include<stdio.h># include<malloc.h>
typedef struct snode*slink;
typedef struct snode{int element;slink next;}
StackNode;
typedef struct lstack*Stack;
typedef struct lstack{
slink top;
}Lstack;
Stack StackInit()
{
Stack S=(Lstack*)malloc(sizeof*S);
S->top=0;
return S;
}
slink NewStackNode()
{
slink p;
if((p=((StackNode*)malloc(sizeof(StackNode)))==0
printf ("ERROR")
else
return p;
}
int StackFull(Stack S)
{
slink p;
if((p=(StackNode*)malloc(sizeof(StackNode)))==0)
return 1;
else
{
free(p);
return 0;
}
}
int StackEmpty(Stack S)
{
slink p;
if(StackFull(S))
printf("Stack is full");
p=NewStackNode();
p->element=x;
p->next=S->top;
S->top=p;
}
int pop(Stack S)
{
slink p;
int x;
if(StackEmpty(s))
printf("Stack is empty");
x=S->top->element;
p=S->top;
S->top=->next;
free (p);
return x;
}
StackItem StackTop(Stack S)
{
if(StackEmoty(S))Error("Stack is empty");
else return S->top->element;
}
void main()
{
int i,x,a,b,c;
Lstack L;
Stack S=&L;
StackInit();
printf("从键盘输入4个入栈的值:")
for(i=0;i<4;i++)
{
scanf("%d",&x);
push(x,S);
}
printf("栈顶元素为:%d\n",StackTop(S))
a=pop(S)
b=pop(S)
c=pop(S)
push(a,S)
printf("栈顶元素为:%d\n",StackTop(S))
}