求助大佬,10分,明明输出结果一样但还是过不了测试点
查看原帖
求助大佬,10分,明明输出结果一样但还是过不了测试点
818552
loe2022楼主2022/11/10 10:59
#include <stdio.h>
#include <string.h>
int main()
{
	char s[100010],c;
	int i=0,hua=0,comp=0;
	while(1)
	{
		scanf("%c",&c);
		if(c=='E')
		{
			break;
		}else{
			if(c!='\n')
			{
				s[i]=c;
				i++;
			}
		}
	}
	if(s[0]!='W'&&s[0]!='L')
	{
		printf("0:0\n");
		printf("\n");
		printf("0:0");
	}else{
		int len1=strlen(s);
	i=0;
	while(i<len1)
	{
		if(s[i]=='W')
		{
			hua++;
		}else{
			comp++;
		}
		i++;
		if(hua>=11&&(hua-comp>=2)||comp>=11&&(comp-hua)>=2||i==len1)
		{
			printf("%d:%d\n",hua,comp);
			hua=0;
			comp=0;
		}
	}
	printf("\n");
	i=0;
	while(i<len1)
	{
		if(s[i]=='W')
		{
			hua++;
		}else{
			comp++;
		}
		i++;
		if(hua>=21&&(hua-comp>=2)||comp>=21&&(comp-hua)>=2||i==len1)
		{
			printf("%d:%d\n",hua,comp);
			hua=0;
			comp=0;
		}
	}
	}
	return 0; 
} 
2022/11/10 10:59
加载中...