#include <stdio.h>
#include <stdlib.h>
int main()
{
int ch;
int braces;
braces = 0;
while( (ch = getchar()) != EOF )
{
if(ch == '{')
braces += 1;
if(ch == '}')
if(braces == 0)
printf("extra closing brace!\n");
else
braces -= 1;
}
if(braces > 0)
printf("%d unmatched opening brace!\n",braces);
return 0;
}
【c语言】从标准输入读取c源代码,并验证所有花括号都成对出现
最新推荐文章于 2023-11-15 17:33:36 发布