Files
python/TangDou/XiTi/1129.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

36 lines
777 B
C++

#include <bits/stdc++.h>
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;
}