<pre name="code" class="html"><pre name="code" class="html"><pre name="code" class="cpp">#include<stdio.h>
int main()
{
int ch;
int i=0;
while((ch=getchar())!=EOF)
{
if(ch=='{')
{
i++;
}
if(ch=='}'&&i==0)
{
printf("no\n");
return 0;
}
if(ch=='}'&&i!=0)
{
i--;
}
}
if(i==0)
{
printf("yes\n");
}
else
{
printf("no\n");
}
return 0;
}
验证花括号的匹配
最新推荐文章于 2020-12-05 23:34:38 发布