4 条题解

  • 0
    @ 2024-11-6 15:09:20

    #include<stdio.h> #include<string.h> int main() { int n; scanf("%d", &n); while (n--) { char arr[1010]; int num = 0; scanf("%s", arr); int sz = strlen(arr); int a = 0; int total = 0; for (int i = 0; i < sz; i++) { num = 0; if (arr[i] == '(') { for (int j = i + 1; arr[j] != ')'&&j<sz; j++) { if (arr[j] >= 'a' && arr[i] <= 'z') { num++;//记录每一次遇到()里的数目 } if (arr[j+1] == ')') { a = 1;//如果有括回来的括号,接收数据 } else { a = 0; } } } if (a==1) { total += num; } } printf("%d\n", total); } return 0; }

    信息

    ID
    211
    时间
    1000ms
    内存
    128MiB
    难度
    8
    标签
    (无)
    递交数
    1524
    已通过
    180
    上传者