#include <stdio.h> int main() { int ch = 0; int count = 0; while ((ch = getchar()) != EOF) { if (ch == ‘{‘) count++; else if (ch == ‘}‘&& count != 0) { count--; } else if (ch == ‘}‘ && count == 0) { printf("匹配不成功\n"); return 0; } } if (count == 0) { printf("匹配成功\n"); } else { printf("匹配不成功\n"); } printf("count=%d", count); return 0; }
时间: 2024-10-11 13:42:48