Cod sursa(job #392009)

Utilizator RengelBotocan Bogdan Rengel Data 6 februarie 2010 17:03:20
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.62 kb
#include<fstream.h>
ifstream fin("cifra.in");
ofstream fout("cifra.out");
unsigned uc,i,t,s,n;
char nn[101];
int main(){
	fin>>t;
	for(i=1;i<=t;i++){
		s=0;
		fin>>nn;
		if(strlen(nn)>1){
			n=(nn[strlen(nn)-2]-48)*10+nn[strlen(nn)-1]-48;
			uc=n%10;
			n=n/10;
			if(n%2==0) s=47*n;
			else s=47*(n-1)+43;
		}
		else
			uc=nn[0]-48;
		if(uc==1) s=s+1;
		else if(uc==2) s=s+5;
		else if(uc==3) s=s+2;
		else if(uc==4) s=s+8;
		else if(uc==5) s=s+3;
		else if(uc==6) s=s+9;
		else if(uc==7) s=s+6;
		else if(uc==8) s=s+2;
		else if(uc==9) s=s+1;
		fout<<s<<'\n';
	}
	fin.close();
	fout.close();
	return 0;
}