Cod sursa(job #259508)

Utilizator shnakoVlad Schnakovszki shnako Data 15 februarie 2009 14:11:55
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.64 kb
#include <stdio.h>
#include <string.h>
int t, a[20], x, k, i, y;
char v[101], c;
int main(void)
{
a[1]=1;a[2]=5;a[3]=2;a[4]=8;a[5]=3;a[6]=9;a[7]=2;a[8]=8;
a[9]=7;a[10]=7;a[11]=8;a[12]=4;a[13]=7;a[14]=3;a[15]=8;a[16]=4;
a[17]=1;a[18]=5;a[19]=4;a[0]=4;
freopen("cifra.in", "r", stdin);
freopen("cifra.out", "w", stdout);
scanf ("%d", &t);
scanf ("%c", &c);
for (i=1;i<=t;i++)
	{
   fgets(v, 101, stdin);
	k=strlen(v);
	if (i!=t)
   	k--;
	if (k==1)
      x=v[k-1]-48;
   else
   	{
      y=(v[k-1]-48+10*(v[k-2]-48))/20;
   	x=(v[k-1]-48+10*(v[k-2]-48))%20;
      }
   printf ("%d\n", (4*y+a[x])%10);
   }
fcloseall();
return 0;
}