Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<fstream>
- using namespace std;
- int n;
- int s=1;
- int cont=1;
- bool y=true;
- int n2=0;
- void cifre(int array[]){
- int t=n;
- int o=cont;
- o--;
- while(t>0){
- array[o]=t%10;
- if(array[o]==7||array[o]==4)
- y=false;
- t/=10;
- o--;
- }
- }
- void cifre2(int array[]){
- int r=1;
- for(int i=0;i<cont;i++){
- if(array[i]==6)
- array[i]=9;
- else if(array[i]==9)
- array[i]=6;
- n2+=array[i]*r;
- r*=10;
- }
- }
- int main(){
- ifstream in;
- in.open("input.txt");
- in>>n;
- ofstream ou;
- ou.open("output.txt");
- while(s<=n){
- s*=10;
- cont++;
- }
- s/=10;
- cont--;
- int array[cont];
- cifre(array);
- if(array[cont-1]==0)
- y=false;
- if(y==false)
- ou<<n;
- else{
- cifre2(array);
- if(n2<n)
- ou<<n2;
- else
- ou<<n;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement