#include<bits/stdc++.h>
using namespace std;
string s;
char a[300];//栈
int top=0;//栈顶指针
int main(){
getline(cin,s);
for(int i=0;i<s.size();i++){
if (s[i]=='('||s[i]=='[') {
a[++top]=s[i];//入栈
} else if (s[i]==')'||s[i]==']')
{
if(s[i]==')'&&a[top]!='('||s[i]==']'&&a[top]!='['){
cout<<"Wrong"<<endl;
return 0;
}else{
top--;
}
}
}
if(top==0) cout<<"OK"<<endl;
else{
cout<<"Wrong"<<endl;
}
return 0;
}
评论区