文章
33
粉丝
78
获赞
3
访问
18.4k
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <string.h>
using namespace std;
int main(){
char s[1000];
cin >> s;
int len =strlen(s);
stack<char> st;
for(int i = 0;i <len;i++){
if(!st.empty()){
char now = st.top();
if((s[i] == ')'&&now == '(') || (s[i] == ']'&&now =='['))
st.pop();
else
st.push(s[i]);
}
else
st.push(s[i]);
}
if(st.empty())
cout << "YES"<<endl;
else
cout <<"NO"<<endl;
return 0;
}
登录后发布评论
暂无评论,来抢沙发