10分蒟蒻求助
查看原帖
10分蒟蒻求助
1040355
zengziyuezzy楼主2023/9/1 15:05
#include<bits/stdc++.h> 
using namespace std;
int main()
{
	stack<char> n;
	string s;
	cin >> s;
	for(int i = 0;i < s.length();i++)
	{
		if(s[i] == '(') n.push(s[i]);
		else if(s[i] == ')')
		{
			if(!n.empty()) n.pop();
			else cout << "NO";
			return 0;	
		} 
	}
	if(n.empty()) cout << "YES";
	else cout << "NO";
	return 0;
}
2023/9/1 15:05
加载中...