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

31 lines
699 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <bits/stdc++.h>
using namespace std;
int pos;
int cnt;
string a, B;
int main() {
cin >> a;
for (int i = 0; i < a.size(); i++)
if (a[i] >= 'A' && a[i] <= 'Z') a[i] += 32;
a = ' ' + a + ' ';
//读入一行数据之前,如果有输入,要getchar();
getchar();
getline(cin, b);
b = ' ' + b + ' ';
for (int i = 0; i < b.size(); i++)
if (b[i] >= 'A' && b[i] <= 'Z') b[i] += 32;
//在b中查找a
int p = 0;
while ((p = b.find(a, p)) != b.npos) {
cnt++;
if (cnt == 1) pos = p;
p++;
}
if (cnt > 0) printf("%d %d\n", cnt, pos);
else printf("%d", -1);
return 0;
}