#include<bits/stdc++.h>
using namespace std;
int main()
{
int a;
char s[1001];
gets(s);
int sl=strlen(s);
for(int i=0;i<=sl;i++)
{
if(s[i]=='(')
{
a++;
}
if(s[i]==')')
{
a--;
}
if(s[i]=='@')
{
break;
}
}
if(a==0)
{
cout<<"YES";
}
else
{
cout<<"NO";
}
return 0;
}
RT,代码如上。
不知道为什么gets无法通过导致CE了,样例输出没有问题,在Dev c++里也正常运行。