Cod sursa(job #2474135)

Utilizator Cosmin2004_InfoMoldoveanu Cosmin Cosmin2004_Info Data 14 octombrie 2019 19:15:12
Problema Cifra Scor 70
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.6 kb
#include <cstdio>
#include <string>
#include <iostream>

using namespace std;
int f[20] = {0, 1, 5, 2, 8, 3, 9, 2, 8, 7, 7, 8, 4, 7, 3, 8, 4, 1, 5, 4};
char s[105];

int main()
{
    freopen("cifra.in","r",stdin);
    freopen("cifra.out","w",stdout);
    int n, i, y, sl;
    char ch;
    scanf("%d%c", &n, &ch);
    for(i = 1; i <= n; i++)
    {
        sl = 0;
        s[0] = '0';
        while(scanf("%c", &s[++sl]) != EOF && s[sl] != '\n');
        sl--;
        y = s[sl] - '0' + 10 * (s[sl - 1] - '0');
        printf("%d\n", (y / 20 * 4 + f[y % 20]) % 10);
    }
    return 0;
}