#include using namespace std; int main() { string a; string b; //输入字符串 getline(cin, a); getline(cin, b); //去掉左右的空格 a = a.substr(a.find_first_not_of(' '), a.find_last_not_of(' ') + 1); //a转小写 transform(a.begin(), a.end(), a.begin(), ::tolower); //b转小写 transform(b.begin(), b.end(), b.begin(), ::tolower); //按空格分割 string temp; stringstream ss(b); //按空格分割 int count = 0; while (ss >> temp) { if (a == temp) count++; } //输出 if (count == 0) cout << -1 << endl; else { int startPos = b.find(a); cout << count << " " << startPos << endl; } return 0; }