Advertisement
chevengur

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

Sep 5th, 2023 (edited)
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4.  
  5.  
  6. using namespace std;
  7.  
  8. void PrintWorryCount(const vector<bool>& is_nervous) {
  9.     // подсчитываем количество элементов в векторе is_nervous, равных true
  10.     std::cout << count(is_nervous.begin(), is_nervous.end(), true);
  11. }
  12.  
  13. int main() {
  14.     // не меняйте содержимое функции main
  15.     PrintWorryCount({ true, true, false, true });
  16.     return 0;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement