先上代码:
#include <iostream>
#include <algorithm>
#include <cctype>
#include <string>
using namespace std;
int main(){
string a,b,temp;
int t=0,p=0,ap=0;
bool flag=false;
getline(cin,a);
getline(cin,b);
transform(a.begin(),a.end(),a.begin(),::tolower);
transform(b.begin(),b.end(),b.begin(),::tolower);
for(int i=0;i<b.length();i++){
while(b[i]!=' '){
temp.push_back(b[i]);
i++;
}
if(a==temp){
if(flag==false){
ap=p;
flag=true;
}
t++;
}
temp="";
p++;
}
if(t!=0)
cout << t << " " << ap << endl;
else
cout << -1 << endl;
return 0;
}
评测情况: