Advertisement
chevengur

СПРИНТ №1 | Базовые алгоритмы | Урок 3: Алгоритмы count и count_if 2/2

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