文章
18
粉丝
0
获赞
87
访问
14.7k
#include<bits/stdc++.h>
using namespace std;
//思路:分别建立左括号和右括号栈,一个正向遍历,一个反向遍历
int main(){
string str;
while(cin>>str){
cout<<str<<endl;
vector<char> ans(str.size(),' ');//数组记录
//左括号栈
stack<char> a;
for(int i=0;i<str.size();i++){
if(str[i]=='('){
a.push(str[i]);
ans[i]=' ';
}
if(str[i]==')'){
if(a.empty()) ans[i]='?';
else if(a.top()=='('){
&nb...
登录后发布评论
暂无评论,来抢沙发