-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10.24.cpp
More file actions
29 lines (25 loc) · 943 Bytes
/
10.24.cpp
File metadata and controls
29 lines (25 loc) · 943 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
28
#include <functional>
#include <vector>
#include <string>
#include <algorithm>
#include <iostream>
std::ostream &print(std::ostream &os, int val, char sep) {
os << val << sep;
return os;
}
bool check_size(const std::string &s, std::string::size_type sz) {
return s.size() < sz;
}
int main() {
std::vector<int> ivec;
for (int temp; std::cin >> temp; ivec.push_back(temp)) ;
std::cout << '\n';
std::for_each(ivec.cbegin(), ivec.cend(), std::bind(print, std::ref(std::cout), std::placeholders::_1, ' '));
std::string s{"1234567890"};
std::vector<int>::const_iterator iter = std::find_if(ivec.cbegin(), ivec.cend(), std::bind(check_size, s, std::placeholders::_1));
if (iter != ivec.end())
std::cout << "\nFirst element that has a value bigger than " << s << "'s size: " << *iter << std::endl;
else
std::cout << "\nThere are no elements in the vector that has a larger value than " << s << "'s size." << std::endl;
return 0;
}