#include <stdio.h>
#include <stdlib.h>
int main()
{
char ch = 0;
int count = 0;
while (((ch = getchar()) != EOF) && (ch!='\n'))
{
if (ch == '{')
{
count++;
}
else if (ch == '}')
{
if (count == 0)
{
printf("not match!\n");
system("pause");
return 0;
}
else
count--;
}
}
if (count == 0)
printf("match!\n");
else
printf("not match!\n");
system("pause");
return 0;
}
编写一个程序,它从标准输入读取C源代码,并验证所有的花括号都正确的成对出现
最新推荐文章于 2021-05-23 02:30:58 发布