五个答案证券,一个运行错误,而且这个题没数组啊
题目
运行结果
#include<bits/stdc++.h>
using namespace std;
string a;
stack<char> x;
signed main() {
getline(cin, a);
for(int i=0;i<a.size();i++){
if(a[i]=='[' || a[i]=='(') x.push(a[i]);
else{
if(a[i]==']'){
if(x.top()=='[' && !x.empty()) x.pop();
else{
cout<<"Wrong";
return 0;
}
}
if(a[i]==')'){
if(x.top()=='(' && !x.empty()) x.pop();
else{
cout<<"Wrong";
return 0;
}
}
}
}
if(!x.empty()) cout<<"Wrong";
else cout<<"OK";
return 0;
}