为什么有4个点过不去,下载数据来看输出也是对的
查看原帖
为什么有4个点过不去,下载数据来看输出也是对的
405747
Botton楼主2021/2/1 21:09
#include <stdio.h>

char ch,str[1000];

int main()
{
    int i,j,cnt = 0;
    gets(&ch);
    gets(str);
    i = 0;
    while(str[i]!='\0')
    {
        i++;
    }
    for(j=0;j<i-1;j++)
    {
        if(str[j]=='V'&&str[j+1]=='K')
        {
            str[j] = '1';
            str[j+1] = '1';
            cnt++;
        }
    }
    for(j=0;j<i-1;j++)
    {
        if(str[j]!='1'&&str[j+1]=='K')
        {
            cnt++;
            break;
        }
        else if(str[j]=='V'&&str[j+1]!='1')
        {
            cnt++;
            break;
        }
    }
    printf("%d\n",cnt);
    return 0;
}

2021/2/1 21:09
加载中...