标签:c语言:验证所有的花括号都正确的成对出现 判断匹配{}问题 if语句的使用
#include <stdio.h>
int main()
{
char ch;
int count=0;
while((ch=getchar())!=EOF)
{
if(ch==‘{‘)
{
count++;
}
else if(ch==‘}‘)
{
if(count==0)
{
printf("不成功匹配\n");
}
else
{
count--;
}
}
}
if(count==0)
{
printf("成功匹配!\n");
}
else
{
printf("不成功匹配!\n");
}
return 0;
}C语言:编写一个程序,它从标准输入(终端)读取C源代码,并验证所有的花括号都正确的成对出现
标签:c语言:验证所有的花括号都正确的成对出现 判断匹配{}问题 if语句的使用
原文地址:http://10740184.blog.51cto.com/10730184/1701640