90分求救!!!!!!!!!!!
查看原帖
90分求救!!!!!!!!!!!
957640
Michelle01楼主2023/8/27 15:16
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<queue>
#include<stack>
using namespace std;

string a;
stack<char> s;
int main() {
	cin >> a;
	for (int i = 0; i < a.size(); i++) {
		if (a[i] == '(') {
			s.push(a[i]);
		}
		if (a[i] == ')' and !s.empty()) {
			if (s.top() == '(') {
				s.pop();
			}
		}
	}
	if (s.empty()) {
		cout << "YES";
		return 0;
	}
	if (!s.empty()) {
		cout << "NO";
		return 0;
	}


	return 0;
}

2023/8/27 15:16
加载中...