@[EarthGiao](/space/show?uid=186489) 啊,这道题遇到左括号时要吧cnt++,右括号是--,注意cnt不能为负数。循环走完后,记得判断cnt是不是等于零
by cindy2007 @ 2019-03-20 18:17:18
@[EarthGiao](/space/show?uid=186489)
帮你改过了
```cpp
#include<iostream>
#include<cstdio> //洛谷70分
#include<stack>
#include<cstring>
char a[100000];
using namespace std;
int main()
{
int len;
scanf("%s",a);
len=strlen(a);
stack<char>s;
for(int j=0;j<len;j++)
{
if(a[j]=='(') s.push(a[j]);
if(a[j]==')')
{
if(s.empty())
{
puts("NO");
return 0;
}
s.pop();
}
}
if(s.empty())
{
cout<<"YES";
}
else cout<<"NO";
return 0;
}
```
by Smile_Cindy @ 2019-03-20 18:29:17
@[cindy2007](/space/show?uid=92991) 谢谢大佬
by EarthGiao @ 2019-03-20 19:07:00
@[Alpha](/space/show?uid=87058) 谢谢大佬
by EarthGiao @ 2019-03-20 19:07:10