Cod sursa(job #176206)

Utilizator M@2Te4iMatei Misarca M@2Te4i Data 10 aprilie 2008 20:47:40
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.59 kb
#include<cstdio>
#include<cstdlib>
#include<cstring>
int v,u,m,i,n;
int x[20]={0,1,5,2,8,3,9,2,8,7,7,8,4,7,3,8,4,1,5,4};
char nr[102];
int main()
{
	freopen("cifra.in","r",stdin);
	freopen("cifra.out","w",stdin);
	for (scanf("%d", &n); n; n--)
	{
	    //scanf("%s", nr);
	    fgets(nr,120,stdin);
	    if (nr[strlen(nr)-1]=='\n')
            nr[strlen(nr)-1]=0;
        if(strlen(nr)<=2)
            u=atoi(nr);
        else
            u=atoi(&nr[strlen(nr)-2]);
        v=u%20;
        m=u/20;
        m=4*m+x[v];
        m=m%10;
        printf("%d\n",m);
    }
	return 0;
}