50分,求调
查看原帖
50分,求调
1511866
Eletronic_Monkey楼主2024/10/31 00:22
#include<stdio.h>
#include<string.h>
int main()
{
	char str1[20],str2[1000001],in[1000001];
	int count=0,flag=0,temp=0;
//	scanf("%s",str1);
	//scanf("%s",str2);
	gets(str1);
	gets(str2);
	char*p,*q;
	int i=0;
	while(str2[i]!='\0')
	{
		if(str2[i]>=65&&str2[i]<=90)
		{
			str2[i]+=32;
		}
		i++;
	}
	i=0;
		while(str1[i]!='\0')
	{
		if(str1[i]>=65&&str1[i]<=90)
		{
			str1[i]+=32;
		}
		i++;
	}
	p=strstr(str2,str1);
	q=str2;
	while(p!=NULL&&(*(p-1)==' '||p==q)&&(*(p+strlen(str1))==' '||*(p+strlen(str1))=='\0'))
	{
		if(flag==0)
		{
			temp=(int)(p-str2);
		}
		count++;
		strcpy(in,&str2[(int)(p-str2)+strlen(str1)]);
		strcpy(str2,in);
		flag=1;
		p=strstr(str2,str1);
	}
	if(flag==0)
	{
		printf("-1");
	}
	else
	{
		printf("%d %d",count,temp);
	}
	return 0;
}
2024/10/31 00:22
加载中...