#include<iostream>
using namespace std;
#define MAXSIZE 50
struct Stack{
int array[MAXSIZE];
int top;
};
typedef Stack STACK;
STACK *Init()
{
STACK *pstack=(STACK*)malloc(sizeof(STACK));
pstack->top=-1;
return pstack;
}
int push(STACK* pstack,int x)
{
if(pstack->top==MAXSIZE-1)
return -1;
pstack->top++;
pstack->array[pstack->top]=x;
return 1;
}
int pop(STACK* pstack)
{
if(pstack->top==-1)
return -1;
pstack->top--;
return pstack->array[pstack->top+1];
}
void display(STACK* pstack)
{
for(int i=0;i<=pstack->top;i++)
cout<<pstack->array[i]<<",";
cout<<"size:"<<pstack->top+1<<endl;
}
int main()
{
STACK* ps=Init();
for(int i=0;i<10;i++)
push(ps,i+10);
cout<<"显示最初的元素:"<<endl;
display(ps);
push(ps,99);
push(ps,88);
cout<<"显示两次压栈后的元素:"<<endl;
display(ps);
int x1=pop(ps);
int x2=pop(ps);
cout<<"显示两次出栈后的元素:"<<endl;
display(ps);
cout<<"第一个出栈者x1:"<<x1<<",第二个出栈者x2:"<<x2<<endl;
delete ps;
return 0;
}