-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10.22.cpp
More file actions
27 lines (24 loc) · 750 Bytes
/
10.22.cpp
File metadata and controls
27 lines (24 loc) · 750 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <functional>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using std::vector;
using std::for_each;
using std::string;
using std::bind;
using namespace std::placeholders;
using std::cout;
using std::endl;
using std::count_if;
bool check_size(const string &s, string::size_type sz) {
return s.size() <= sz;
}
int main() {
vector<string> vec = {"auto", "mama", "hailer", "killers", "ninjas", "apple", "pear", "rocket", "au", "hatefully", "worldpeace", "hammer", "sources"};
for_each(vec.cbegin(), vec.cend(), [](const string &s) -> void {cout << s << ' ';});
cout << endl;
vector<string>::size_type count = count_if(vec.cbegin(), vec.cend(), bind(check_size, _1, 6));
cout << count << endl;
return 0;
}