Advertisement
Guest User

Untitled

a guest
Jun 9th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. #include <algorithm>
  4.  
  5. #include <math.h>
  6.  
  7. #include <fstream>
  8.  
  9. using namespace std;
  10.  
  11. ifstream fin ("input.txt");
  12. ofstream fout ("output.txt");
  13.  
  14. int n=0, k=0, z=0, d=0, h=0;
  15.  
  16.  
  17. int main() {
  18. fin >> n;
  19. h=n;
  20. for(int tmp=n; tmp>=10;tmp=tmp/10)
  21. k++;
  22. k++;
  23. int m[k], q[k];
  24. for (int l; l<k; l++){
  25. q[l]= h%10;
  26. h=h/10;
  27. }
  28.  
  29. for (int l=k-1; l>=0; l--){
  30. m[l]= q[z];
  31. z++;
  32. }
  33. for (int l; l<k; l++){
  34. if(m[l]==6){
  35. m[l]=9;
  36. } else if (m[l]==9){
  37. m[l]= 6;
  38. } else if (m[l]== 3 || m[l]== 4 || m[l]== 7){
  39. fout<< n;
  40. return 0;
  41. }
  42. }
  43. if (q[0]==0 || m[0]==0){
  44. fout<< n;
  45. return 0;
  46. }
  47.  
  48. for (int l; l<k; l++){
  49. d= d+ m[l]*pow(10, l);
  50. }
  51. if(d>n){
  52. fout<< n;
  53. } else {
  54. fout<< d;
  55. }
  56.  
  57. return 0;
  58.  
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement