#include
#include
using namespace std;
bool isRight(char* str)
{
if(strNULL)
return false;
stacksk;
while(*str)
{
if(!sk.empty())
{
if(*str’)’&&sk.top()’(’)
{
sk.pop();
}
else if(*str’}’&&sk.top()’{’)
{
sk.pop();
}
else if(*str’]’&&sk.top()==’[’)
{
sk.pop();
}
else
sk.push(*str);
}
else
sk.push(*str);
str++;
}
return sk.empty();
}
int main(void)
{
char str[100]=" ";
cin>>str;
int jud=isRight(str);
if(jud)
cout<<“isRight”;
else
cout<<“isFalse”;
cout<<endl;
return 0;
}
括号匹配
最新推荐文章于 2023-01-26 21:02:06 发布