#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源代码,并验证所有的花括号都正确的成对出现
原文:http://10740184.blog.51cto.com/10730184/1701640