#include <stdio.h>
#include <string.h>
char convert(char);
int main(void)
{
char word[11],article[1000001];
scanf("%s",word);
getchar();
scanf("%[^\n]",article);
int count=0;
int first_exist=-1;
for(int i=0;article[i]!='\0';i++)
{
if((i==0&&article[i]!=' ')||(i>0&&article[i-1]==' '&&article[i]!=' '))
{
for(int j=0;article[i+j]!=' ';j++)
{
char c=convert(word[j]);
if(article[i+j]==word[j]||article[i+j]==c)
{
if(j==strlen(word)-1)
{
if(article[i+j+1]==' ')
{
count++;
if(count==1)
{
first_exist=i;
}
}
break;
}
}
else
{
break;
}
}
}
}
if(count!=0)
{
printf("%d %d",count,first_exist);
}
else
{
printf("-1");
}
return 0;
}
char convert(char ch)
{
char c;
if(ch>='a'&&ch<='z')
{
c=ch-'a'+'A';
}
else
{
c=ch-'A'+'a';
}
return c;
}
洛谷AC了。 本地输入: to t tot to t to 输出: 1 7
请问这是为什么呢