Advertisement
Guest User

Untitled

a guest
Dec 18th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include <iostream>
  2. #include<vector>
  3. #include<fstream>
  4. using namespace std;
  5. vector<int> v;
  6. int n=0;
  7. int n2=0;
  8. void numero(){
  9. int s=1;
  10. for(int i=v.size()-1;i>-1;i--){
  11. n+=v[i]*s;
  12. s*=10;
  13. }
  14. }
  15. void numero2(){
  16. int d=1;
  17. for(int i=0;i<v.size();i++){
  18. if(v[i]==6)
  19. v[i]=9;
  20. else if(v[i]==9)
  21. v[i]=6;
  22. n2+=v[i]*d;
  23. d*=10;
  24. }
  25. }
  26. int main() {
  27. ifstream in;
  28. ofstream ou;
  29. in.open("input.txt");
  30. ou.open("output.txt");
  31. char a;
  32. int b;
  33. bool tre=true;
  34. while(!in.eof()){
  35. in>>a;
  36. a-=48;
  37. v.push_back(a);
  38. b=a;
  39. if(b==4||b==7)
  40. tre=false;
  41. }
  42. numero();
  43. numero2();
  44. if(tre==true&&n2<n)
  45. ou<<n2;
  46. else
  47. ou<<n;
  48. return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement