好多重题,这个咋还是入门
2026-03-18 21:00:32
发布于:上海
2阅读
0回复
0点赞
#include<iostream>\可用万能头#include<bits/stdc++.h>
#include<stack>
#include<string>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
stack<char>a;
string b;
cin>>b;
for(int i=0;i<b.length();i++)
{
if(b[i]'(')
{
a.push('(');
}
else if(b[i]')')
{
if(a.empty())
{
cout<<"NO"<<endl;
return 0;
}
a.pop();
}
}
if(a.empty())
{
cout<<"YES"<<endl;
}
else
{
cout<<"NO"<<endl;
}
return 0;
}
全部评论 1
点个赞吧

4天前 来自 上海
0








有帮助,赞一个