Advertisement
Dizzy3113

Untitled

Nov 10th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int calcul(int n)
  6. {
  7. int i=0, p=0;
  8. while(n)
  9. {
  10. if(n%2==0)
  11. p++;
  12. else
  13. i++;
  14. n=n/10;
  15. }
  16.  
  17. if(i>p)
  18. return i-p;
  19. else
  20. return p-i;
  21. }
  22.  
  23. int main()
  24. {
  25. cout<<calcul(92465);
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement