提交时间:2023-08-22 16:16:28
运行 ID: 99331
#include <stdio.h> int main() { char a[256]; int temp=0; for(int i=0; ;i++) { scanf("%c",&a[i]); temp++; if(a[i]=='\n') { break; } } int sum1=0,sum2=0,sum3=0,sum4=0,sum5=0,sum6=0; for(int i=0;i<temp;i++) { if(a[i]=='(') { if(a[i+1]==')')sum1++; else break; } else if(a[i]==')') { if(a[i-1]=='(')sum2++; else break } else if(a[i]=='[') { if(a[i+1]==']')sum3++; else break; } else if(a[i]==']') { if(a[i-1]=='[')sum4++; else break; } else if(a[i]=='{') { if(a[i+1]=='}')sum5++; else break; } else if(a[i]=='}') { if(a[i-1]=='{')sum6++; else break; } } if(sum1==sum2 && sum3==sum4 && sum5==sum6) { printf("OK"); } else { printf("Wrong"); } return 0; }