Advertisement
edutedu

V36 PR3

Sep 27th, 2020
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4.  
  5. int cifra(int a)
  6. {
  7. int k;
  8. if(a==0)
  9. return a;
  10. while(a%2!=0)
  11. {
  12. a=a/10;
  13. }
  14. k=a%10;
  15. if(a==0)
  16. return -1;
  17. else
  18. return k;
  19. }
  20.  
  21. int main()
  22. {
  23. int n, frecv[5], a;
  24. ifstream f("bac.in");
  25. f>>n;
  26. for(int i=0; i<=8; i+=2)
  27. frecv[i]=0;
  28. for(int i=0; i<n; i++)
  29. {
  30. f>>a;
  31. if(cifra(a)!=-1)
  32. frecv[cifra(a)]++;
  33. }
  34. for(int i=8; i>=0; i-=2){
  35. while(frecv[i]>0)
  36. {
  37. cout<<i;
  38. frecv[i]--;
  39. }
  40. }
  41. return 0;
  42. }
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement