Cod sursa(job #209140)

Utilizator pitbullpitbulll pitbull Data 20 septembrie 2008 22:19:43
Problema Cifra Scor 0
Compilator c Status done
Runda Arhiva de probleme Marime 0.5 kb
# include <string.h>
# include <stdio.h>
# define NMAX 105

int i,N,res,resaux,sum;
int v[]={0,1,5,2,8,3,9,2,8,7};
char str[NMAX];

int main (){
	FILE* f=fopen("cifra.in","rt");
	FILE* g=fopen("cifra.out","wt");
	
	fscanf(f,"%d",&N);
	
	for (i=0;i<N;i++){
		fscanf(f,"%s",str);
		res=str[strlen(str)-1]-'0';
		
		resaux=0;
		if(strlen(str)>=2)
			resaux=str[strlen(str)-2]-'0';
		
		sum=v[res]+resaux*5;
		
		fprintf(g,"%d\n",sum%10);
	}
	
	fclose(f);
	fclose(g);
	return 0;
}