90求助,WA#3
查看原帖
90求助,WA#3
1041965
goIdie楼主2023/12/3 19:24
#include<bits/stdc++.h>
using namespace std;
int main(){
	stack<char>s;
	char c;
	while(cin>>c){
		if(c=='('){
			s.push(c);
		}
		if(c==')'){
			if(!s.empty()){
				if(s.top()=='('&&!s.empty()){
					s.pop();
				}
				else{
					cout<<"NO";
					return 0;
				}
			}
		}
	}
	if(s.empty()){
		cout<<"YES";
	}
	else{
		cout<<"NO";
	}
	
}
2023/12/3 19:24
加载中...