#include<iostream>
#include<cstdio>
#include<cstring>
#include<cctype>
using namespace std;
char s[10000001],word[101];
int sum,j;
bool bk=false;
int first=-1;
int main(){
scanf("%s",word);
getchar();
gets(s);
int slen=strlen(s);
int wlen=strlen(word);
s[slen+1]=' ';
for(int i=0;i<slen;i++) s[i]=tolower(s[i]);
for(int i=0;i<wlen;i++) word[i]=tolower(word[i]);
for(int i=0;i<slen;i++)
{
if(i==0 || s[i-1]==' ')
{
for(j=0;j<wlen;j++)
{
if(s[i+j]!=word[j]) break;
else continue;
}
}
else continue;
if((j==wlen && s[i+j]==' ') || (j==wlen && (i+j)==slen))
{
if(!bk) bk=true,first=i;
sum+=1;
}
}
if(sum!=0 && first!=-1){printf("%d %d",sum,first);}
else puts("-1");
return 0;
}
测评姬如此说道:
/tmp/compiler_57s9y9qt/src: 在函数‘int main()’中:
/tmp/compiler_57s9y9qt/src:16:2: 错误:‘gets’ was not declared in this scope; did you mean ‘fgets’?
16 | gets(s);
| ^~~~
| fgets
试了好几遍都没用!求助!