编辑代码

#include<stdio.h>
typedef char SType;
//出栈
int pop(SType *s,int top){
    if(top==-1){
        printf("empty stack\n");
        return -1;
    }
    printf("pop %c\n",s[top]);
    return --top;
}

//入栈
int push(SType *s,int top, SType ch){
    s[++top]=ch;
    printf("push %c\n",s[top]);
    return top;
}

int main(){
    char s[100];
    int top=-1;
    top=push(s, top, 'a');
    top=push(s, top, 'b');
    top=push(s, top, 'c');
    top=push(s, top, 'd');
    top=pop(s, top);
    top=pop(s, top);
    top=pop(s, top);
    top=pop(s, top);
    top=pop(s, top);
    return 0;
}