Advertisement
SelinD

V87s3e4

Mar 12th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #include<iostream>
  2. #include<cmath>
  3. #include<fstream>
  4. using namespace std;
  5. ifstream fin("bac1.txt.cpp");
  6.  
  7. int suma(int x)
  8. {
  9. int spar=0,simp=0,c;
  10. while(x!=0)
  11. {
  12. c=x%10;
  13. if(c%2==0) spar=spar+c;
  14. else simp=simp+c;
  15. x=x/10;
  16. }
  17. if(spar==simp) return 1;
  18. else return 0;
  19. }
  20. int main()
  21. {
  22. int x,ap=0,minim=INT_MAX;
  23. while(fin>>x)
  24. {
  25. if(suma(x)==1)
  26. {
  27. if(x<minim)
  28. {
  29. minim=x;
  30. ap=1;
  31. }
  32. else
  33. {
  34. if(x==minim) ap++;
  35. }
  36. }
  37. }
  38. cout<<minim<<" "<<ap;
  39. }
  40. //22031 9021 22031 1021 2011 10012 1021 457008 99882
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement