|
发表于 2018-7-24 20:29:53
|
显示全部楼层
- #include <bits/stdc++.h>
- using namespace std;
- #define func(str)\
- for(int i = 0;i < str.size(); ++i)\
- if(isupper(str[i]))\
- str[i] = tolower(str[i])
- int main(void)
- {
- string s1, s2, temp;
- vector<string>v;
- cin >> s1;
- std::cin.get(); // '\n'
- getline(cin, s2);
- func(s1);
- func(s2);
-
- stringstream ss;
- ss << s2;
- while(ss >> temp)
- {
- v.push_back(temp);
- }
-
- int cnt = 0;
- int flag = 1;
- int pos = -1;
- cout << (s1 == v[0]) << endl;
- for(int i = 0; i < v.size(); ++i)
- {
- if(v[i] == s1)
- {
- cnt++;
- if(flag)
- pos = i, flag = 0;
- }
- }
- if(cnt == 0)
- cout << -1 << endl;
- else
- cout << cnt << " " << pos << endl;
- return 0;
- }
复制代码
|
|