Pagini recente » Cod sursa (job #1702142) | Cod sursa (job #2122866) | Cod sursa (job #1035134) | Cod sursa (job #2752721) | Cod sursa (job #665566)
Cod sursa(job #665566)
#include<stdio.h>
#include<string.h>
int a,b,d,e,f,g,T=0,uc,h;
FILE * "cifra.in";
FILE * "cifra.out";
char c[102];
int main()
{
fopen(cifra.in,"r");
fscanf(cifra.in,"%d",&T);
for(a=1;a<=T;a++)
{
fscanf(cifra.in,"%s",&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;
fopen(cifra.out,"w");
fclose(cifra.in);
fprintf(cifra.out,"%d",uc%10);
fprintf(cifra.out,"\n");
}
fclose(cifra.out);
}