Cod sursa(job #287606)

Utilizator udrescu_cristiUdrescu Cristian udrescu_cristi Data 24 martie 2009 23:23:31
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.61 kb
#include<iostream.h>
#include<stdio.h>
FILE *f=fopen("cifra.in","r"),*g=fopen("cifra.out","w");
 int main()
{
long long m,n,v[20],i,c,d=0,a[10000],k;
char x2;
v[1]=1; v[6]=6;
v[2]=4; v[7]=9; 
v[3]=9; v[8]=4;
v[4]=6; v[9]=1;
v[5]=5; v[10]=0;
fscanf(f,"%ld\n",&m);
for(i=1;i<=m;i++)
{
a[0]=0;
d=0;
x2='m';
while(x2!='\n'&&!feof(f))
{
 fscanf(f,"%c",&x2);
d++;
a[d]=x2-48;
}
d--;
if(!a[d]) c=(a[d-1]*5)%10;
else
{
k=a[d];
c=(a[d-1]*5+v[k])%10;
}
 fprintf(g,"%ld\n",c);
}
return 0;
}