Cod sursa(job #940153)

Utilizator horatiu11Ilie Ovidiu Horatiu horatiu11 Data 15 aprilie 2013 18:32:34
Problema Cifra Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.65 kb
#include<fstream>
#include<string.h>
using namespace std;
int T, t, exp, rest, p, nr, i, aux, cif;
char c[105];
int u[21]={0, 1, 5, 2, 8, 3, 9, 2, 8, 7, 7, 8, 4, 7, 3, 8, 4, 1, 5, 4, 4};
ifstream f("cifra.in");
ofstream g("cifra.out");
int main()
{
    f>>T;
    for(;T--;)
    {
        f>>c;
        t=strlen(c);
        if(t>1) nr=(c[t-2]-'0')*10+(c[t-1]-'0');
        else nr=c[t-1]-'0';
        if(t>=2)
        {
            if(nr>=21)
            {
                aux=4*(nr/20)+u[nr%20];
                g<<aux%10<<"\n";
            }
            else g<<u[nr]<<"\n";
        }
        else g<<u[nr]<<"\n";
    }
    return 0;
}