Cod sursa(job #3255720)

Utilizator alex.iovita.23@gmail.comIovita Alexandru [email protected] Data 12 noiembrie 2024 00:51:50
Problema Factorial Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.93 kb
#include<bits/stdc++.h>
using namespace std;
ifstream f("codificare.in");
ofstream g("codificare.out");
int codpi(int n)
{
    int nou = 0 , p = 1;
    while(n)
    {
        if(n % 2 == 0)
        {
            nou = nou + (n % 10 + 1) * p;
        }
        else
        {
            nou = nou + (n % 10 - 1) * p;
        }
        n = n / 10;
        p = p * 10;
    }
    return nou;
}
int main()
{
    int c;
    f>>c;
    if(c == 1)
    {
        int n , x , min , max;
        min=max=-1;
        f>>n;
        for(int i=1;i<=n;i++)
        {
            f>>x;
            int cod = codpi(x);
            if(cod>x)
            {
                if(min == -1 && max == -1)
                {
                    min = max = x;
                }
                if(x>max) max=x;
                if(x<min) min=x;
            }
        }
        g<<min<<" "<<max;
    }
    if(c == 2)
    {

    }
}