Advertisement
Guest User

8

a guest
Nov 18th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <algorithm>
  4. #include <vector>
  5.  
  6. using namespace std;
  7.  
  8. bool pred(int a)
  9. {
  10.     int cntOfChet = 0, cntOfNechet = 0;
  11.     while(a){
  12.         if((a % 10) % 2 == 0){
  13.             cntOfChet++;
  14.         }else{
  15.             cntOfNechet++;
  16.         }
  17.         a /= 10;
  18.     }
  19.     if(cntOfChet == cntOfNechet){
  20.         return true;
  21.     }else{
  22.         return false;
  23.     }
  24. }
  25.  
  26. int main()
  27. {
  28.     vector<int> v;
  29.     int x;
  30.     while(cin >> x){
  31.         v.push_back(x);
  32.     }
  33.     cout << count_if(v.begin(), v.end(), pred);
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement