#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define Stack_Size 6
#define TRUE 1
#define FALSE 0
typedef struct //定义数据类型
{
char elem[Stack_Size];
int top;
}SeqStack;
//初始化顺序栈
void InitStack(SeqStack *S)
{
S->top=-1; //top指针拉置=-1,压入一个元素后,top指针位置=0; 栈顶位置=栈顶实际位置
}
//栈为空时返回真,否则返回假
int IsEmptyStack(SeqStack *S)
{
return S->top==-1?FALSE:TRUE;
}
//栈是满的返回真,否则返回假
int IsFull(SeqStack *S)
{
return S->top==Stack_Size-1?TRUE:FALSE;
}
//入栈
void Push(SeqStack *S) //进栈 ,将元素压入栈中
{
int i;
char ch;
if(S->top<=Stack_Size-1) //压入栈中的元素不能超过栈的最大存储
{
printf(“输入入栈字符元素:\n”);
for(i=0;i<Stack_Size;i++)
{