Advertisement
Ilya_konstantinov

is_even_func

Jan 28th, 2024
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | Source Code | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <vector>
  4.  
  5. using std::cin;
  6. using std::cout;
  7. using std::sort;
  8.  
  9. bool is_even(int a) { // Проверка четности
  10.   return (a%2) == 0;
  11. }
  12.  
  13. int main() {
  14.   int n; cin >> n;
  15.   std::vector<int> v(n);
  16.   for(int &el : v) cin >> el;
  17.   cout << std::count_if(v.begin(), v.end(), is_even);
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement