Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<vector>
- #include<fstream>
- using namespace std;
- vector<int> v;
- int n=0;
- int n2=0;
- void numero(){
- int s=1;
- for(int i=v.size()-1;i>-1;i--){
- n+=v[i]*s;
- s*=10;
- }
- }
- void numero2(){
- int d=1;
- for(int i=0;i<v.size();i++){
- if(v[i]==6)
- v[i]=9;
- else if(v[i]==9)
- v[i]=6;
- n2+=v[i]*d;
- d*=10;
- }
- }
- int main() {
- ifstream in;
- ofstream ou;
- in.open("input.txt");
- ou.open("output.txt");
- char a;
- int b;
- bool tre=true;
- while(!in.eof()){
- in>>a;
- a-=48;
- v.push_back(a);
- b=a;
- if(b==4||b==7)
- tre=false;
- }
- numero();
- numero2();
- if(tre==true&&n2<n)
- ou<<n2;
- else
- ou<<n;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement