#include<stdio.h>
#include<stdbool.h>
#include<string.h>
#define maxsize 10
typedef char Elemtype;
typedef struct Stack
{
Elemtype data[maxsize];
int top;
}Stack;
//初始化
void initStack(Stack s)
{
s.top=-1;
}
//判断是否空
int IsEmpty(Stack s)
{
if(s.top==-1)
return 1;
else
return 0;
}
//判断是否满
int IsFull(Stack s)
{
if(s.top==maxsize-1)
return 1;
else
return 0;
}
//入栈
void Push(Stack s,Elemtype x)
{
if(!IsFull(s))
{
s.top++;
s.data[s.top]=x;
}
else
printf("栈満\n");
}
//出栈
void Pop(Stack s,Elemtype x)
{
if(!IsEmpty(s))
{
x=s.data[s.top];
s.top--;
}
else
printf("栈空\n");
}
//销栈
void Destory(Stack s)
{
s.top=-1;
}