全re,样例ide和本地都测试过了
查看原帖
全re,样例ide和本地都测试过了
218974
wsadjkl0楼主2021/3/28 13:03

下了第一个测试数据 in:td Td tLWCsrmt out:1 2

奇怪输出不应该是1 0吗 不知道哪里有问题55555555555连续第三个全re的题了

#include<stdio.h>
#include<string.h>
char s[1000001],q[11];
int main()
{
	int i,j,count=1;
	char *p;
	scanf("%s\n",q);
	i=0;
    while(q[i]!='\0')
    {
	if(q[i]>='A'&&q[i]<='Z')
		q[i]+=32;
		i++;
	}
    
	gets(s);
   
	i=0;
    while(s[i]!='\0')
    {
	if(s[i]>='A'&&s[i]<='Z')
		s[i]+=32;
		i++;
	}
	i=0;
p=strstr(s,q);
if(!((*(p+strlen(q))==' '&&*(p-1)==' ')||(*(p+strlen(q))=='\0'&&*(p-1)==' ')||(*(p+strlen(q))==' '&&*(p-1)==NULL))) printf("%d\n",-1);
else
{
	j=(int)(p-s);
i=(int)(p-&s[i])+strlen(q);

while((p=strstr(&s[i],q))!=NULL)
{
	if((*(p+strlen(q))==' '&&*(p-1)==' ')||(*(p+strlen(q))=='\0'&&*(p-1)==' ')||(*(p+strlen(q))=='\0'&&*(p-1)==NULL))
	{
	  i=(int)(p-s)+strlen(q);
	  
	  count++;
	}
}
printf("%d %d\n",count,j);
}

return 0;

}
2021/3/28 13:03
加载中...