fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. int countEvenOdd(int n)
  6. {
  7. int even_count = 0;
  8. int odd_count = 0;
  9. while (n > 0)
  10. {
  11. int rem = n % 10;
  12. if (rem % 2 == 0)
  13. even_count++;
  14. else
  15. odd_count++;
  16. n = n / 10;
  17. }
  18. cout << "Even count : "
  19. << even_count;
  20. cout << "\nOdd count : "
  21. << odd_count;
  22. if (even_count % 2 == 0 &&
  23. odd_count % 2 != 0)
  24. return 1;
  25. else
  26. return 0;
  27. }
  28.  
  29.  
  30. int main()
  31. {
  32. int n;
  33. n = 2335453;
  34. int t = countEvenOdd(n);
  35. if (t == 1)
  36. cout << "\nYES" << endl;
  37. else
  38. cout << "\nNO" << endl;
  39. return 0;
  40. }
Success #stdin #stdout 0s 5508KB
stdin
Standard input is empty
stdout
Even count : 2
Odd count : 5
YES