![](https://i-blog.csdnimg.cn/blog_migrate/042454156deb7239dd6c5e804a29dbfc.png)
#include <stdlib.h>
#include <stdio.h>
#include "G:\JS\mystack.h"
int main()
{
sqstack s;
int e;
initstack(s);
char ch;
while (1)
{
scanf("%c",&ch);
if (ch==10)
break;
if (ch=='(')
push(s,ch);
else
if (ch=')')
{
if (emptystack(s))
{
printf("\n not match--type1...more ) \n");
return 0;
}
else
pop(s,e);
}
}
if (emptystack(s))
{
printf("\n match\n");
return 0;
}
else
{
printf("\n not match....( more \n");
return 0;
}
}
#include <stdlib.h>
#include <stdio.h>
#define stackinitsize 20
#define stackincrement 8
typedef struct{
int *base;
int *top;
int stacksize;
}sqstack;
int initstack(sqstack &s)
{s.base=(int * ) malloc(stackinitsize*sizeof(int));
s.top=s.base;
s.stacksize=stackinitsize;
return 1;
}
int push(sqstack &s,int e)
{
*(s.top)=e;
s.top++;
return 1;
}
int gettop(sqstack s)
{
return *(s.top-1);
}
int emptystack(sqstack s)
{if (s.top==s.base) return 1;
else return 0;
}
int pop(sqstack &s,int &e)
{ if (emptystack(s)) return 0;
--s.top;
e=*(s.top);
return 1;
}