#include<iostream>
#include<malloc.h>
using namespace std;
#define STACKSIZE 10
#define SIZEADD 5
typedef char ElemType;
typedef struct
{
ElemType *pBottom;
ElemType *pTop;
int Stacksize;
}Stack;
void InitStack(Stack &S)
{
S.pBottom = new ElemType[STACKSIZE];
S.pTop = S.pBottom;
S.Stacksize = STACKSIZE;
}
void DestroyStack(Stack &S)
{
delete[]S.pBottom;
S.pBottom = NULL;
S.pTop = NULL;
S.Stacksize = 0;
}
void ClearStack(Stack &S)
{
S.pTop = S.pBottom;
}
bool StackEmpty(Stack S)
{
if (S.pBottom == S.pTop)
{
cout << "The Stack is empty !" << endl;
return true;
}
else
return false;
}
int StackLength(Stack S)
{
return (S.pTop - S.pBottom);
}
void Visit(ElemType c)
{
cout << c << " ";
}
void Push(Stack &S, ElemType c)
{
if (S.pTop - S.pBottom >= S.Stacksize)
{
S.pBottom = (ElemType*)realloc(S.pBottom, (S.Stacksize +