顺序栈问题
# include<stdio.h># include<stdlib.h>
#define MAXLEN 10
typedef struct
{int data[MAXLEN];
int top;
}Seqstack;
Seqstack *Snull()
{Seqstack *s;
s=malloc(sizeof(Seqstack));
s->top=-1;
return s;
}
int Push(Seqstack *s,int x)
{if(s->top==MAXLEN-1)
return 0;
else
{s->top++;
s->data[s->top]=x;
return 1;
}
}
int Pop(Seqstack *s,int x)
{if(s->top=-1)
return 0;
else
{x=s->data[s->top];
s->top--;
return 1;
}
int Readtop(Seqstack *s)
{
if(SEmpty(s))
return 0;
else
return(s->data[s->top]);
}
int Sempty(Seqstack *s)
{if(s->top==-1)
return 1;
else
return 0;
}
int Sfull(Seqstack *s)
{if(s->top==MAXLEN)
return 1;
else
return 0;
}
void main()
{
Seqstack *s;
int x;
Snull();
Push(s,x);
Pop(s,x);
Readtop(s);
Sempty(s);
Sfull(s);
}
我运行了 Readtop函数有三个错误!!!
可我看不出来唉。。。 请大家看看哈。。。。。。。。。。