随机分数……
查看原帖
随机分数……
551094
siyeansh楼主2021/10/11 20:59
#include <bits/stdc++.h>
using namespace std;
char a[20], s[1000010];
int main() {
	gets(a + 1);
	gets(s + 1);
	a[0] = ' '; strcat(a, " ");
	s[0] = ' '; strcat(s, " ");
	for (int i = 0; a[i]; i++)
		if (a[i] >= 'A' && a[i] <= 'Z') a[i] += 32;
	for (int i = 0; s[i]; i++)
		if (s[i] >= 'A' && s[i] <= 'Z') s[i] += 32;
	int first, cnt = 0, p = 0;
	while ( (p = strstr(s + p, a) - s) >= 0) {
		cnt++;
		if (cnt == 1) first = p;
		p++;
	}
	if (cnt == 0) printf("-1\n");
	else printf("%d %d\n", cnt, first);
	return 0;
}
2021/10/11 20:59
加载中...