顺序栈

#define maxsize 10
typdef struct
{
    elementype ele[maxsize];
    int top;
}sqstacktp;
void InitStack(sqstacktp *s)
{
    s->top=0;//顺序栈为空 
}
void main()
{
    void InitStack(sqstacktp *s);
    sqstacktp *s;
    s=(sqstacktp *)malloc(sizeof(sqstacktp));
    InitStack(s);
}
int StackEmpty(sqstacktp *s)//判断栈空 
{
    if(s->top>0)
    {
        return 0;
    }
    else
        return 1;
}
void Push(sqstacktp *s,elementype x)//进栈 
{
    if(s->top==maxsize)
        printf("Overflow");
    else
        s->elem[s->top++]=x;//x进栈 
}
Elementype Pop(sqstacktp *s)//栈不空则删除栈顶元素。 
{
    if(s->top==0)
        return NULL;
    else
    {
        s->top--;
        return s->ele[s->top];
    }
}
int Size(sqstacktp *s)
{
    return s->top;
}
elementype Top(sqstacktp *s)
{
    if(s->top==0)
    {
        return NULL;
    }
    else
    {
        return(s->ele[s->top-1]);
    }
}
原文地址:https://www.cnblogs.com/claudia529/p/11104262.html