int match(char a[],int n)
{
char sq[maxSize];
int top=-1;
for(int i=0;i<n;i++)
{
if(a[i]=='(')
sq[++top]=a[i];
if(a[i]=='[')
sq[++top]=a[i];
if(a[i]==')')
{
if(top==-1)
return 0;
if(sq[top]=='(')
--top;
}
if(a[i]==']')
{
if(top==-1)
return 0;
if(sq[top]=='[')
--top;
}
}
if(top==-1)
return 1;
else
return 0;
}
转载于:https://my.oschina.net/zhujunxxxxx/blog/311989