Praktikum_mf

Базовые алгоритмы/Алгоритмы count и count_if/Задание 2

Sep 30th, 2021
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <string>
  4. #include <vector>
  5.  
  6. using namespace std;
  7.  
  8. bool StartsWithA(const string& str) {
  9.     return !str.empty() && (str[0] == 'A' || str[0] == 'a');
  10. }
  11.  
  12. int CountStartsWithA(const vector<string>& xs) {
  13.     return count_if(xs.begin(), xs.end(), StartsWithA);
  14. }
  15.  
  16. int main() {
  17.     // не меняйте тело main
  18.     cout << CountStartsWithA({"And"s, "another"s, "one"s, "gone"s, "another"s, "one"s, "bites"s, "the"s, "dust"s}) << endl;
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment