#include <iostream>
#define MAXSIZE 50
using namespace std;
bool push(int *stack,int PushX,int &top)
{
if(top==MAXSIZE)
{
cout<<"filling";
return false;
}
else{
stack[top++]=PushX;
return true;
}
}
bool pop(int *stack,int &X,int &top)
{
if(top==0)
{
cout<<"empty";
return false;
}
else{
X=stack[--top]; //stack是个数组指针
return true;
}
}
int main(int argc, char *argv[])
{
int stack[MAXSIZE]={0};
int top = 0;
int X=10;
for(int i=0;i<3;i++)
{
if(push(stack,X++,top))
cout<<stack[i]<<endl;
cout<<top<<endl; //共压入top个元素
}
for(int i=0;i<3;i++)
{
if(pop(stack,X,top))
cout<<X<<endl;
}
return 0;
}