文章
34
粉丝
18
获赞
6
访问
14.4k
#include <bits/stdc++.h>
using namespace std;
int main(){
string s;
while(cin >> s){
stack<char> ss;
for(int i = 0;i < s.size();i ++){
if(!ss.empty()){
char ch = ss.top();
if((ch == '(' && s[i] == ')') || (ch == '{' && s[i] == '}') || (ch == '[' && s[i] == ']') || (ch == '<' && s[i] == '>')){
ss.pop();
}else {
ss.push(s[i]);
}
}else{
ss.push(s[i]);
}
}
if(ss.empty()){
cout << "yes" << endl;
}else{
cout << "no" << endl;
}
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发