#include<stdio.h>
int main()
{
int ch;
int a;
while ((ch=getchar())!=EOF)
{
if (ch=='{')
{
a++;
}
else if(ch=='}'&&a!=0)
{
a--;
}
else if(ch=='}'&&a==0)
{
printf("unmatched\n");
return 0;
}
}
if(a==0)
{
printf("matched\n");
}
else
{
printf("unmathed\n");
}
return 0;
}
判断花括号是否匹配
最新推荐文章于 2022-03-25 23:09:41 发布