Advertisement
a53

numere_77

a53
Dec 5th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. bool echilibrat(int n)
  5. {
  6. int scp=0,sci=0;
  7. while(n)
  8. {
  9. if(n%10%2)
  10. sci+=n%10;
  11. else
  12. scp+=n%10;
  13. n/=10;
  14. }
  15. if(sci==scp)
  16. return true;
  17. return false;
  18. }
  19.  
  20. int main()
  21. {
  22. int a,b;
  23. cin>>a>>b;
  24. unsigned long long int s=0;
  25. for(int i=a;i<=b;++i)
  26. if(echilibrat(i))
  27. s+=i;
  28. cout<<s;
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement