Advertisement
Guest User

Untitled

a guest
Dec 18th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. #include <iostream>
  2. #include<fstream>
  3. using namespace std;
  4. int n;
  5. int s=1;
  6. int cont=1;
  7. bool y=true;
  8. int n2=0;
  9. void cifre(int array[]){
  10. int t=n;
  11. int o=cont;
  12. o--;
  13. while(t>0){
  14. array[o]=t%10;
  15. if(array[o]==7||array[o]==4)
  16. y=false;
  17. t/=10;
  18. o--;
  19.  
  20. }
  21. }
  22. void cifre2(int array[]){
  23. int r=1;
  24. for(int i=0;i<cont;i++){
  25. if(array[i]==6)
  26. array[i]=9;
  27. else if(array[i]==9)
  28. array[i]=6;
  29. n2+=array[i]*r;
  30. r*=10;
  31. }
  32. }
  33. int main(){
  34. ifstream in;
  35. in.open("input.txt");
  36. in>>n;
  37. ofstream ou;
  38. ou.open("output.txt");
  39. while(s<=n){
  40. s*=10;
  41. cont++;
  42. }
  43. s/=10;
  44. cont--;
  45. int array[cont];
  46. cifre(array);
  47. if(array[cont-1]==0)
  48. y=false;
  49. if(y==false)
  50. ou<<n;
  51. else{
  52. cifre2(array);
  53. if(n2<n)
  54. ou<<n2;
  55. else
  56. ou<<n;
  57. }
  58. return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement