7 条题解

  • 1
    @ 2025-10-28 20:54:11
    #include<stdio.h>
    #include<string.h>
    int main(){
    	int n;
    	char str[1010];
    	scanf("%d",&n);
    	while(n--){
    		scanf("%s",str);
    		int len = strlen(str);
    		int ans = 0;
    		int a[1010] = {0};
    		int b[1010] = {0};
    		int x = 0;
    		int y = 0;
    		for(int i = 0;i < len;i++){
            if(str[i] == '('){
            	a[x] = i;
            	x++;
    		}
    		if(str[i] == ')'){
    			b[y] = i;
    			y++;
    		}
    		}
    		for(int i = 0;i <=x;i++){
    			for(int j = a[i] + 1;j < b[i];j++){
    				if(str[j]>='a'&&str[j]<='z'){
    					ans++;
    				}
    			}
    		}
    		printf("%d\n",ans);
    	}
    }//提示说会不出现(fs(hf)adf)这种情况但是没有说不会出现(sdfad)sa)f)这种情况哦👀️ 
    

    信息

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