Cod sursa(job #3136470)

Utilizator alexandrubilaBila Alexandru-Mihai alexandrubila Data 6 iunie 2023 14:47:27
Problema Cifra Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.89 kb
#include <fstream>
#include <cstdlib>
#include <cstring>
using namespace std;

ifstream f("cifra.in");
ofstream g("cifra.out");

int T;

int solve(int x)
{
    if (x == 0 || x == 9)
        return 7;
    if (x == 1)
        return 1;
    if (x == 2)
        return 5;
    if (x == 3 || x == 7)
        return 2;
    if (x == 4 || x == 8)
        return 8;
    if (x == 5)
        return 3;
    return 9; ///x == 6
}

int charToInt(const char* x)
{
    int len = strlen(x);
    if (len == 1)
        return atoi(x);
    return atoi(x) % 100;
}

void citire()
{
    f >> T;
    while (T--)
    {
        char x[110];
        f >> x;
        int val = charToInt(x);
        if (val < 10)
            g << solve(val) << '\n';
        else
            g << ((val / 10) * solve(val % 10)) % 10 << '\n';

    }
}


int main()
{
    citire();
    return 0;
}