文章
59
粉丝
0
获赞
235
访问
5.0k
#include <bits/stdc++.h>
using namespace std;
int main()
{
stack<char> st;
string s;
cin>>s;
int mark=1;
for(int i=0;i<s.size();i++)
{
if(s[i]=='['||s[i]=='(')
st.push(s[i]);
else if(!st.empty())
{
char t=st.top();
if((s[i]-t==')'-'(')||(s[i]-t==']'-'['))
{
st.pop();
continue;
}
else
{
mark=0;
break;
}
}
else{
mark=0;
break;
}
}
if(st.empty()&&mark==1)
cout<<"YES";
else
cout<<"NO";
cout<<endl;
return 0;
}
登录后发布评论
暂无评论,来抢沙发