c语言入门级问题,代码已写,但不知哪里出错,求各位帮帮我

Description

Petya loves football very much. One day, as he was watching a football match, he was writing the players' current positions on a piece of paper. To simplify the situation he depicted it as a string consisting of zeroes and ones. A zero corresponds to players of one team; a one corresponds to players of another team. If there are at least 7 players of some team standing one after another, then the situation is considered dangerous. For example, the situation 00100110111111101 is dangerous and 11110111011101 is not. You are given the current situation. Determine whether it is dangerous or not.

Input

The first input line contains a non-empty string consisting of characters "0" and "1", which represents players. The length of the string does not exceed 100 characters. There's at least one player from each team present on the field.

Output

Print "YES" if the situation is dangerous. Otherwise, print "NO".

Sample Input
Input

001001

Output

NO

Input

1000000001

Output

YES

#include<stdio.h>
#include<string.h>
int main()
{
    int i,length,count=0;
    char a[105];

    while(scanf("%s",a)!=EOF)
    {
        length=strlen(a);
        for(i=0;i<length;i++)
        {
            if(a[i]==a[i-1])
            {
                count+=1;
            }
            else
            {
                count=count;
            }
        }
        if(count>=7)
        {
            printf("YES\n");
        }
        else
        {
            printf("NO\n");
        }
    }
    return 0;
}

改一下逻辑:

 #include<stdio.h>
#include<string.h>
int main()
{
    int i,length,count=0;
    char a[105];
    while(scanf("%s",a)!=EOF)
    {
        count=0;//初始化
        length=strlen(a);
        for(i=1;i<length;i++) //修改,每一个和前一个比较,就要从i=1开始
        {
            if(a[i]==a[i-1])
            {
                count+=1;
            }
            else
            {
                count=0;//修改,不同就重新计数
            }
            if(count>=7)
            {
                break;
            }
        }
        if(count>=1)
        {
            printf("YES\n");
        }
        else
        {
            printf("NO\n");
        }
    }
    return 0;
}
 #include<stdio.h>
#include<string.h>
int main()
{
    int i,length,count=0;
    char a[105];
    while(scanf("%s",a)!=EOF)
    {
        count=0;//初始化
        length=strlen(a);
        for(i=1;i<length;i++) //修改,每一个和前一个比较,就要从i=1开始
        {
            if(a[i]==a[i-1])
            {
                count+=1;
            }
            else
            {
                count=0;//修改,不同就重新计数
            }
            if(count>=7)
            {
                break;
            }
        }
        if(count>=7)
        {
            printf("YES\n");
        }
        else
        {
            printf("NO\n");
        }
    }
    return 0;
}

这个对了,两个相等,count应该是2,所以count初始值应该为1,不是0.

 #include<stdio.h>
#include<string.h>
int main()
{
    int i,length,count=0;
    char a[105];
    while(scanf("%s",a)!=EOF)
    {
        count=1;//初始化
        length=strlen(a);
        for(i=1;i<length;i++) //修改,每一个和前一个比较,就要从i=1开始
        {
            if(a[i]==a[i-1])
            {
                count+=1;
            }
            else
            {
                count=1;//修改,不同就重新计数
            }
            if(count>=7)
            {
                break;
            }
        }
        if(count>=7)
        {
            printf("YES\n");
        }
        else
        {
            printf("NO\n");
        }
    }
    return 0;
}