iterator find(pos_beg,pos_end,data) //找到相同的
iterator find_if(pos_beg,pos_end,cond) //找到符合条件的
count(pos_beg,pos_end,data) //统计
iterator find_if(pos_beg,pos_end,cond) //找到符合条件的
count(pos_beg,pos_end,data) //统计
count_if(pos_beg,pos_end,data,cond) //符合条件的才统计
#include <iostream>
#include <algorithm>
#include <cctype>
#include <string>
using namespace std;
//判断第一个字母是否是大写
bool init_upper(string &str)
{
return isupper(str[0]);
}
bool has_o(const string& str)
{
return str.find_first_of("oO") != string::npos;
}
int main()
{
string a[5] = {"abc","good","day","Look","God"};
string *p = find(a,a+5,"good"); //返回的是迭代器,但对于基本类型就是指针
cout << (p == a+5?"没找到":"找到")<< "good" << endl;
p = find_if(a,a+5,init_upper);
if(p == a+5) cout << "没有找到大写字母开头的字符串" << endl;
else cout << "找到了" << *p << endl;
cout << count_if(a,a+5,init_upper) << endl;
cout << count_if(a,a+5,has_o) << endl;
}