//4.编写一个程序,它从标准输入读取C源代码,并验证所有的花括号都正确的成对出现。
#include<stdio.h>
int main()
{
int ch;
int count = 0;
while ((ch =getchar())!= EOF)
{
if (ch == '{')
{
count++;
}
else if (ch == '}')//}{不匹配
{
if (0 == count)
{
printf("not match\n");
system("pause");
return 1;
}
count--;
}
else
{
}
}
if (0 == count)
{
printf("match\n");
}
if (0 != count)
{
printf("not match\n");
}
system("pause");
return 0;
}