//任务,用栈判断括号序列是否匹配
bool BracketsCheck(char* str)
{
SqStack S;
Init(S);
int i = 0;
char x;
while (str[i]!='\0')
{
switch (str[i])
{
case '(':Push(S, '('); break;
case '[':Push(S, '['); break;
case '{':Push(S, '{'); break;
case ')':
Pop(S, x);
if (x != '(') return false; break;
case ']':
Pop(S, x);
if (x != '[') return false; break;
case '}':
Pop(S, x);
if (x != '{') return false; break;
default:
break;
}
i++;
}
if (StackEmpty(S))
{
return true;
}
else
{
return false ;
}
}
int main()
{
char str[] = "{[()]}";
cout<<BracketsCheck(str);
return 0;
}