/* * Standard containers, std::vector, exercise 4. */ #include #include #include #include #include #include #include using namespace std; using namespace std::placeholders; struct first_character_equal { bool operator()(const string& first, const string& second) const { for (auto c : second) { if (tolower(first[0]) == tolower(c)) return true; } return false; } typedef bool result_type; typedef string first_argument_type; typedef string second_argument_type; }; int main() { vector cars{ istream_iterator(cin), istream_iterator() }; sort(begin(cars), end(cars)); copy_if(begin(cars), end(cars), ostream_iterator(cout, "\n"), bind(first_character_equal(), _1, "abc")); return 0; }