Cod sursa(job #2314193)

Utilizator minecraft3Vintila Valentin Ioan minecraft3 Data 8 ianuarie 2019 01:34:54
Problema Cifra Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.59 kb
#include <bits/stdc++.h>

using namespace std;

int main()
{
    ifstream fin("cifra.in");
    ofstream fout("cifra.out");
    int v[]  = {0, 1, 4, 7, 6, 5, 6, 3, 6, 9, 0, 1, 6, 3, 6, 5, 6, 7, 4, 9}, hs = 94;
    int ps[] = {0, 1, 5, 2, 8, 3, 9, 2, 8, 7, 7, 8, 4, 7, 3, 8, 4, 1, 5, 4};

    int n, x;
    char s[105];
    fin >> n;

    do
    {
        fin >> s;
        x = strlen(s);
        if(x == 1)
            x = s[0] - '0';
        else
            x = s[x-1] - '0' + (s[x-2] - '0') * 10;
        (fout << (4 * (x / 20) + ps[x % 20]) % 10).put('\n');
    } while(--n);
}