比赛 |
板子大赛 |
评测结果 |
AAAAAA |
题目名称 |
多种括号匹配 |
最终得分 |
100 |
用户昵称 |
李奇文 |
运行时间 |
0.018 s |
代码语言 |
C++ |
内存使用 |
3.30 MiB |
提交时间 |
2025-01-22 10:30:35 |
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
string a;
bool c(string a){
stack <char> s;
for(int i=0;i<a.length();i++){
if(a[i]=='['||a[i]=='('){
s.push(a[i]);
}else if(a[i]==')'){
if(!s.empty()&&s.top()=='(') s.pop();
else return false;
}else if(a[i]==']'){
if(!s.empty()&&s.top()=='[') s.pop();
else return false;
}else{
return false;
}
}
if(s.empty()) return true;
else return false;
}
int main(){
freopen("check.in","r",stdin);
freopen("check.out","w",stdout);
string a;
cin>>a;
if(c(a)){
cout<<"OK";
}else{
cout<<"Wrong";
}
return 0;
}