#include <iostream>
using namespace std;
#define Stack_Size 200
typedef struct sqStack
{
char *elem;
int top;
int stackSize;
}sqStack;
void initStack_Sq(sqStack &S)
{
S.elem=new char[Stack_Size];
S.top=-1;
S.stackSize=Stack_Size;
}
void creatStack_Sq(sqStack &S,int n)
{
initStack_Sq(S);
for(int i=0;i<n;i++)
{
cin>>S.elem[i];
S.top++;
}
}
void destroyStack_Sq(sqStack S)
{
delete []S.elem;
S.top=-1;
S.stackSize=0;
}
void creatStack_Sq(sqStack &S,int n)
{
initStack_Sq(S);
for(int i=0;i<n;i++)
{
cin>>S.elem[i];
S.top++;
}
}
void destroyStack_Sq(sqStack S)
{
delete []S.elem;
S.top=-1;
S.stackSize=0;
}
void push(sqStack &S,char x)
{
if(S.top==Stack_Size-1)
cout<<"Stack Overflow!";
S.elem[++S.top]=x;
}
char pop(sqStack &S)
{
char x;
if(S.top==-1)
cout<<"Stack Empty!";
x=S.elem[S.top--];
return x;
}
void main()
{
sqStack S;
creatStack_Sq(S,5);
push(S,'a');
cout<<pop(S)<<endl;
destroyStack_Sq(S);
}
using namespace std;
#define Stack_Size 200
typedef struct sqStack
{
char *elem;
int top;
int stackSize;
}sqStack;
void initStack_Sq(sqStack &S)
{
S.elem=new char[Stack_Size];
S.top=-1;
S.stackSize=Stack_Size;
}
void creatStack_Sq(sqStack &S,int n)
{
initStack_Sq(S);
for(int i=0;i<n;i++)
{
cin>>S.elem[i];
S.top++;
}
}
void destroyStack_Sq(sqStack S)
{
delete []S.elem;
S.top=-1;
S.stackSize=0;
}
void creatStack_Sq(sqStack &S,int n)
{
initStack_Sq(S);
for(int i=0;i<n;i++)
{
cin>>S.elem[i];
S.top++;
}
}
void destroyStack_Sq(sqStack S)
{
delete []S.elem;
S.top=-1;
S.stackSize=0;
}
void push(sqStack &S,char x)
{
if(S.top==Stack_Size-1)
cout<<"Stack Overflow!";
S.elem[++S.top]=x;
}
char pop(sqStack &S)
{
char x;
if(S.top==-1)
cout<<"Stack Empty!";
x=S.elem[S.top--];
return x;
}
void main()
{
sqStack S;
creatStack_Sq(S,5);
push(S,'a');
cout<<pop(S)<<endl;
destroyStack_Sq(S);
}