求助
查看原帖
求助
478697
xuanye楼主2022/6/17 21:47
#include<bits/stdc++.h>
using namespace std;
char s[1000005];
stack<char> st;
int main(){
	cin>>s;
	for(int i=0;i<=strlen(s)-1;i++){
		if(s[i]=='('){
			st.push(s[i]);
		}
		if(!st.empty()){
			if(s[i]==')'&&st.top()=='('){
				st.pop();
			}
		}
		else{
			if(s[i]==')'){
				st.push(s[i]);
			}
		}

	}
	cout<<strlen(s)-st.size();
	return 0;
}

哪里有问题?QAQ

2022/6/17 21:47
加载中...