用栈解决括号匹配问题`
#include<cstdio>
#include<cstdlib>
#define maxn 20
using namespace std;
char c[256];
bool judge(char c[256])
{
int top=0,i=0;
while(c[i]!='@')
{
if(c[i]=='(')
top++;
if(c[i]==')')
{
if(top>0)
top--;
else
return 0;
}
i++;
}
if(top!=0)
return 0;
else
return 1;
}
int main()
{
scanf("%s",c);
if(judge(c))
printf("YES");
else
printf("NO");
return 0;
}