Cod sursa(job #665510)

Utilizator emyll96Constantinescu Emil emyll96 Data 22 ianuarie 2012 09:32:58
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.8 kb
#include<stdio.h>
#include<string.h>
int a,b,d,e,f,g,uc,h;
FILE*x;
FILE*y;
char c[102];
int main()
{
	x=fopen("cifra.in","r");
	fscanf(x,"%d",&g);
	for(a=1;a<=g;a++)
	{
		fscanf(x,"%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;
										y=fopen("cifra.out","w");
		fclose(x);
		fprintf(y,"%d",uc%10);
		fprintf(y,"\n");
	}
	fclose(y);
}