#include <iostream>
using namespace std;
int main()

{
string s;
cin>>s;
int count=0;
for(int i=0;i<s.length();i++)
{
if(s[i]=='(')
count++;
else if(s[i]==')')
if(count==0)
{
cout<<"not match"<<endl;
return 1;
}
count--;
}
cout<<"match"<<endl;
return 0;
}

用于判断表达式的括号是否匹配。同理可以扩展成判断{}的匹配。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-07
猜你喜欢
  • 2021-11-05
  • 2021-08-11
  • 2022-12-23
  • 2021-08-18
  • 2022-12-23
  • 2021-08-08
相关资源
相似解决方案