60分求解
查看原帖
60分求解
768259
liulechen楼主2024/11/5 17:49
#include<bits/stdc++.h>
using namespace std;
string s;
stack<char> q; 
int main(){
	cin>>s;
	for(int i=0;i<s.length()-1;i++){
		if(s[i]=='(') q.push(s[i]);
		else if(s[i]==')' && q.top()=='(') q.pop(); 
	}
	if(q.empty()) cout<<"YES";
	else cout<<"NO";
	return 0;
}

恳求大佬的帮助

2024/11/5 17:49
加载中...