Advertisement
a53

cifremaxmin1

a53
Feb 9th, 2020
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #include <fstream>
  2.  
  3. using namespace std;
  4. ifstream fin("cifmaxmin.in");
  5. ofstream fout("cifmaxmin.out");
  6. int n,x,cmin,cmax,nmin,nmax,catepare,cateimpare;
  7. int main()
  8. {
  9. int i,uc,nr,cx;
  10. nmin=100;
  11. nmax=9;
  12. fin>>n;
  13. for(i=1; i<=n; i++)
  14. {
  15. fin>>x;
  16. cx=x;
  17. cmin=9;
  18. cmax=0;
  19. while(cx!=0)
  20. {
  21. uc=cx%10;
  22. if(uc<cmin)
  23. cmin=uc;
  24. if(uc>cmax)
  25. cmax=uc;
  26. cx=cx/10;
  27. }
  28. if(x%2==0)
  29. {
  30. nr=cmax*10+cmin;
  31. catepare++;
  32. if(nr>nmax)
  33. nmax=nr;
  34. }
  35. else
  36. {
  37. nr=cmin*10+cmax;
  38. cateimpare++;
  39. if(nr<nmin)
  40. nmin=nr;
  41. }
  42. }
  43. fout<<nmax<<" "<<catepare<<" "<<nmin<<" "<<cateimpare;
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement