Advertisement
a53

toate

a53
Jun 19th, 2021
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. ifstream fin("toate.in");
  5. ofstream fout("toate.out");
  6. int n, x, xnou, xmax;
  7.  
  8. int main()
  9. {
  10. fin>>n;
  11. for(int i=1; i<=n; ++i)
  12. {
  13. fin>>x;
  14. int p=1;
  15. xnou=0;
  16. while(x)
  17. {
  18. if(x%10!=9)
  19. {
  20. xnou=xnou+(x%10)*p;
  21. p*=10;
  22. }
  23. x/=10;
  24. }
  25. if(xnou>xmax)
  26. xmax=xnou;
  27. }
  28. fout<<xmax;
  29. return 0;
  30. }
  31. /**
  32. SO
  33. #include <fstream>
  34.  
  35. using namespace std;
  36. ifstream f("toate.in");
  37. ofstream g("toate.out");
  38. int n,i,a,x,p,r,maxim;
  39.  
  40. int main()
  41. {
  42. f >> n;
  43. maxim = 0;
  44. for(i = 1; i <= n; i++)
  45. {
  46. f >> x;
  47. a = 0;
  48. p = 1;
  49. while(x != 0)
  50. {
  51. r = x % 10;
  52. if(r != 9)
  53. {
  54. a = a + r * p;
  55. p = p * 10;
  56. }
  57. x = x / 10;
  58. }
  59. if(a > maxim)
  60. maxim = a;
  61. }
  62. g << maxim;
  63. return 0;
  64. }
  65. */
  66.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement