14.42
a:
int main(int argc, char *argv[]) {
list<int > st;
st.insert(st.end(),1201);
st.insert(st.end(), 11);
st.insert(st.end(), 1231);
cout << count_if(st.begin(), st.end(), bind(greater<int>(), std::placeholders::_1, 1024)) << endl;
for (;;);
return 0;
}
b:
int main(int argc, char *argv[]) {
list<string > st;
st.insert(st.end(),"pooh");
st.insert(st.end(), "poohx");
st.insert(st.end(), "poohs");
cout << *find_if(st.begin(), st.end(), bind(not_equal_to<string>(), std::placeholders::_1, "pooh")) << endl;
for (;;);
return 0;
}
c:
int main(int argc, char *argv[]) {
list<int > st;
st.insert(st.end(),5);
st.insert(st.end(), 10);
st.insert(st.end(), 15);
transform(st.begin(), st.end(), st.begin(), bind(multiplies<int>(), std::placeholders::_1, 2));
for_each(st.begin(), st.end(), [](const int & i) { cout << i << ends; });
for (;;);
return 0;
}
14.43
int main(int argc, char *argv[]) {
list<int > st;
st.insert(st.end(),5);
st.insert(st.end(), 10);
st.insert(st.end(), 15);
int theNum = 3;
auto it = find_if(st.begin(),st.end(), bind(not_equal_to<int>(), bind(modulus<int>(), _1, theNum), 0));
if(it != st.end()){
cout << " find not by " << theNum << " clear multiplies number " << *it << endl;
}else{
cout << "not find" << endl;
}
for (;;);
return 0;
}