编辑代码

#include <stdio.h>
#include "malloc.h"
#define datatype char
#define MAXSIZE 100
typedef struct
{
    datatype data[MAXSIZE];
    int top;
}SEQSTACK;

SEQSTACK *s;
// 初始化空栈
void Init_Stack(SEQSTACK *s)
{
    s->top =-1;
}
//判断空操作
int Stack_Empty(SEQSTACK *s)
{
    if(s->top==-1)
    return 1;
    else
    return 0;
}
//入栈操作
void Push_Stack(SEQSTACK *s,datatype x)
{
    if(s->top==-1)
    printf("Stack full\n");
    else
    {
        s->top++;
        s->data[s->top]=x;
    }
}
//取栈顶元素操作
datatype Gettop_Stack(SEQSTACK *s)
{
    datatype x;
    if(Stack_Empty(s))
    {
        printf("Stack empty.\n");
        x=NULL;
    }
    else
        x=s-data[s->top];
    return x;
}
//出栈操作
datatype Pop_Stack(SEQSTACK *s)
{
    datatype x;
    if(Stack_Empty(s))
    {
        printf("stack empty\n");
        x=NULL;
    }
    else
    {
        x=s->data[s->top];
        s->top--;
    }
    return x;
}
int main () {
    
    return 0;
}