Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/56.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C-无法继续遍历第二个字符串_C - Fatal编程技术网

C-无法继续遍历第二个字符串

C-无法继续遍历第二个字符串,c,C,谁能告诉我我做错了什么 问题陈述: 我的代码: #include <stdio.h> #include<string.h> int is_vowel(char a) { if(a==97||a==101||a==105||a==111||a==117){ return(1); } return(0); } int main() { //code int t,i; scanf("%d",&t);

谁能告诉我我做错了什么

问题陈述:

我的代码:

#include <stdio.h>
#include<string.h>
int is_vowel(char a) {
    if(a==97||a==101||a==105||a==111||a==117){
        return(1);
    }
    return(0);
}
int main() {
    //code
    int t,i;
    scanf("%d",&t);
    for(i=0;i<t;i++){
        char str[100];
        scanf("%s",str);
        printf("%s",str);
        int c_cnsnt=0;
        int c_vwl=0;
        int g_b=1;//suppose good
        for(int j=0;j<strlen(str);j++){
            //("%c",str[j]);
            int num=is_vowel(str[j]);
            printf("Debug %c %d %d\n",str[j],num,strlen(str));
            if(is_vowel(str[j])) {
                c_vwl++;
            }
            else { c_cnsnt++;}
            if(c_vwl==c_cnsnt){
                c_cnsnt=0;
                c_vwl=0; 
            }
            else {
                if(c_vwl>5||c_cnsnt>=3){
                    g_b=0;
                    break;
                }
            }

        }
        printf("%d\n",g_b);
    }

    return 0;
}
输出:

1
0
我的解决方案链接:


为什么for循环对第二个字符串不起作用?

提示:在增加另一个字符串(例如
{c_vwl++;c_cnsnt=0;}
)后,必须清除辅音和元音计数,而不是在它们相等时,并且始终测试您的不良状况


我不会给你一个示例代码。祝你好运

我已经改进了我的代码,现在它为第一个tc提供了正确的ans,但循环并没有在第二个字符串上迭代为什么?请看我做的!!Thanks@confused如果您愿意,请编辑您的问题,以包含您提出的有效解决方案。
1
0