#include <stdio.h>#include <stdlib.h>#include <malloc.h>#include <iostream.h>#define ElemType char#define Status int#define STACKSIZE 10#define OK 1#define ERROR 0typedef struct...{ ElemType *base; //栈底指针,顺序栈中,其值不变 ElemType *top; //栈定指针 int stacksize;}SqStack;Status Init(SqStack &s)...{ s.base=(ElemType *)malloc(STACKSIZE*sizeof(ElemType)); if(!s.base)...{ printf("分配内存失败 "); return ERROR; } s.top=s.base; s.stacksize=STACKSIZE; return OK;}Status Push(SqStack &s,ElemType e)...{ if(s.top-s.base>=s.stacksize)...{ s.base=(ElemType *)realloc(s.base,(s.stacksize+5)*sizeof(ElemType)); if(!s.base)...{ printf("增加内存空间失败 "); return ERROR; } s.top=s.base+s.stacksize; s.stacksize+=5; } *s.top++=e; return OK;}Status Pop(SqStack &s,ElemType &e)...{ if(s.top==s.base)...{ printf("空栈 "); return ERROR; } e=*--s.top; return OK;}void out(int i,char e1,char e2)...{ if(i) printf("%c匹配%c ",e1,e2); else printf("%c失配%c ",e1,e2);}void main()...{ SqStack s; ElemType e; ElemType e1; Init(s); for(int i=0;i<10;i++)...{ printf("输入第%d个元素:",i+1); cin>>e; if(e=='['||e==']'||e=='('||e==')'||e=='{'||e=='}')...{ if(e=='['||e=='('||e=='{') Push(s,e); else...{ Pop(s,e1); switch(e)...{ case']':if(e1=='[') out(1,e1,e); else out(0,e1,e); break; case'}':if(e1=='{') out(1,e1,e); else out(0,e1,e); break; case')':if(e1=='(') out(1,e1,e); else out(0,e1,e); break; } } }else...{ i--; } }/**//* for(i=1;i<=10;i++){ Pop(s,e); printf("%3d:%3c ",i,e); }*/}