#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; }
时间: 2024-08-05 09:46:01