#include#includeusing namespace std;#define Stack_size 20typedef struct Stack{int elem[Stack_size];int top;}Stack;Stack * init(){//初始化一个空栈Stack *S=(Stack *)malloc(sizeof(Stack));S->top=-1;return S;}void print(Stack *S){//打印栈元素for(int i=0;i<=S->top;i++){cout<<S->elem[i]<<" ";}cout<&lhttps://www.3tt.net/?mod=artinfo&aid=392t;endl;}int push(Stack *S,int num){//入栈if(S->top==Stack_size-1)return -1;S->top++;S->elem[S->top]=num;return 1;}int pop(Stack *S){//出栈if(S->top!=-1){int num=S->elem[S->top--];return num;}return -99999;}int main(int argc, char const *argv[]){Stack *S;S=init();push(S,1);print(S);push(S,2);push(S,3);push(S,4);print(S);cout<<"pop "<<pop(S)<<endl;cout<<"pop "<<pop(S)<<endl;cout<<"pop "<<pop(S)<<endl;return 0;}