bool matching(string exp){
SqStack St;
St.Init();
int i=0;
while(exp[i]){
if(exp[i]=='('||exp[i]=='['){
St.Push(exp[i++]);
}
else {
if(St.Empty()){
return 0;
}
char a=St.GetTop();
St.Pop();
if((a=='('&&exp[i]==')')||
a=='['&&exp[i]==']'){
i++;
}
else return 0;
}
}
return St.Empty();
}
括号匹配pta
最新推荐文章于 2025-04-26 19:53:27 发布