#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
bool GT3(string s);
int main()
{
vector<string> svec;
string word;
while (cin >> word) {
svec.push_back(word);
}
vector<string>::iterator it = find_if(svec.begin(),
svec.end(), GT3);
if (it == svec.end()) {
cout << "not found." << endl;
} else {
cout << "found at index " << it-svec.begin() << endl;
}
getchar();
return 0;
}
bool GT3(string s) {
return s.size() > 3;
}
STL find_if demo
最新推荐文章于 2023-03-09 11:42:06 发布