#include<stdio.h> #include<stdlib.h> #include<conio.h> int main() { int ch; int braces=0; while((ch=getchar())!=EOF) { if(ch=='{') braces++; if(ch=='}') if(braces==0) printf("Extra closing brace!\n"); else braces--; } if(braces>0) printf("%d braces not matched",braces); system("pause"); return 0; }
资料:http://baike.baidu.com/