文章
54
粉丝
0
获赞
12
访问
1.2k
#include<iostream>
#include<stack>
using namespace std;
int n;
string str;
bool check()
{
stack<char> st;
for(int i=0;i<str.size();i++)
{
if(str[i]=='{')
{
if(st.empty())
st.push(str[i]);
else
{
if(st.top()=='['||st.top()=='('||st.top()=='<')
return false;
else
st.push(str[i]);
}
}
else if(str[i]=='[')
{
if(st.empty())
st.push(str[i]);
else
{
if(st.top()=='('||st.top()=='<')
return false;
else
st.push(str[i]);
}
}
else if(str[i]=='(')
{
if(st.empty())
st.push(str[i]);
else
{
if(st.top()=='<')
return false;
else
st.push(str[i]);
}
}
else if(str[i]=='<')
st.push(str[i]);
else
{
if(st.empty())
return false;
...
登录后发布评论
暂无评论,来抢沙发