#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#define Maxsize 50
typedef int ElemType;
typedef struct
{
ElemType data[Maxsize];
int top;
} SqStack;
void initStack(SqStack &S)
{
S.top = -1;
printf("初始化成功\n");
}
bool push(SqStack &S, ElemType &x)
{
if (S.top == Maxsize - 1)
{
printf("入栈失败\n");
return false;
}
else
{
S.data[++S.top] = x;
printf("入栈成功\n");
return true;
}
}
bool pop(SqStack &S, ElemType &x)
{
if (S.top == -1)
{
printf("出栈失败\n");
return false;
}
else
{
x = S.data[S.top--];
printf("出栈成功\n");
return true;
}
}
bool stackEmpty(SqStack S)
{
if (S.top == -1)
return true;
else
return false;
}
bool stackFull(SqStack S)
{
if (S.top == Maxsize - 1)
return true;
else
return false;
}
int main(int argc, char const *argv[])
{
SqStack NewSqStack;
initStack(NewSqStack);
system("pause");
return 0;
}