Advertisement
Guest User

Untitled

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