- #define _CRT_SECURE_NO_WARNINGS
- #include
- #include
- #include
- #include
- #include
- #include
- #include
- #include
-
- #define MAX 1024
- using namespace std;
-
- bool isOK(char *s1,char *s2) {
- if (strlen(s1) != strlen(s2))
- return false;
- while (*s1) {
- if (*s1 != *s2) {
- if (tolower(*s1) != tolower(*s2))
- return false;
- }
- s1++;
- s2++;
- }
- return true;
- }
- int main() {
- char sub[1024];
- char buf[1024];
-
- int pos = -1;//第一次出现位置
- int cnt = 0;
-
- cin >> sub;
- getchar();
- cin.getline(buf,sizeof(buf));
-
- //cout << sub<
- //cout << buf<
- char* p = buf;
- char* q = buf;
- while (*q) {
- if (*q == ' ') {
- *q = '\0';
- if (isOK(p, sub)) {
- cnt += 1;
- if (pos == -1)
- pos = p - buf;
- }
- *q = ' ';
- p = q + 1;
- }
- q++;
- }
-
- if (pos == -1) {
- cout << pos;
- }
- else {
- cout << cnt <<" " << pos;
- }
-
-
- return 0;
- }