int main()
{
int ch = 0;
int count = 0;
while ((ch = getchar()) != EOF)//ctrl z
{
if (ch == '{')
count++;
else if (ch == '}'&&count == 0)
{
printf("不匹配\n");
return 0;
}
else if (ch == '}'&&count != 0)
{
count--;
}
}
if (count == 0)
{
printf("匹配\n");
}
else
{
printf("不匹配\n");
}
system("pause");
return 0;
}
编写程序,它从标准输入读取c源代码,并验证所有的花括号都正确的成对出现
猜你喜欢
转载自blog.csdn.net/weixin_41892460/article/details/82807326
今日推荐
周排行