Pagini recente » Cod sursa (job #577774) | Cod sursa (job #230062) | Cod sursa (job #859132) | Cod sursa (job #1711677) | Cod sursa (job #665478)
Cod sursa(job #665478)
#include<stdio.h>
#include<string.h>
int a,b,d,e,f,g,T,uc,h;
FILE*x;
FILE*y;
int c[102];
int main()
{
x=fopen("cifra.in","r");
fscanf(x,"%d",&T);
for(a=1;a<=T;a++)
{
fscanf(x,"%c",&c);
b=strlen(c);
d=c[b-1]-'0';e=c[b-2]-'0';
h=e*10+d;
if (h>10)
{
if(e%2==0)
{
uc=e+6*e+6*e+e;
}
else
uc=e+4+7+6*e+5+6*e+3+6+e;
}
if (h==1||d==1) uc=uc+1;else
if (h==2||d==2)uc=uc+5;else
if (h==3||d==3)uc=uc+2;else
if (h==4||d==4)uc=uc+8;else
if (h==5||d==5)uc=uc+3;else
if (h==6||d==6)uc=uc+9;else
if (h==7||d==7)uc=uc+6;else
if (h==8||d==8)uc=uc+2;else
if (h==9||d==9)uc=uc+8;
if(h==0) uc=1;
y=fopen("cifra.out","w");
fclose(x);
fprintf(y,"%d",uc%10);
fprintf(y,"\n");
}
fclose(y);
}