Cod sursa(job #178424)
Utilizator | Data | 14 aprilie 2008 16:20:25 | |
---|---|---|---|
Problema | Cifra | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.61 kb |
#include<fstream.h>
#include<iostream.h>
#include<math.h>
#include<stdio.h>
#include<string.h>
int main(void)
{
long int t,r,i,j,x[10],m,n,coun,h;
fstream f,g;
char y[105];
char *ptr;
x[0]=0; x[1]=1; x[2]=5; x[3]=2; x[4]=8;
x[5]=3; x[6]=9; x[7]=2; x[8]=8; x[9]=7;
f.open("cifra.in",ios::in);
g.open("cifra.out",ios::out);
f>>t;
for(i=1;i<=t;i++)
{
f>>y;
ptr=strchr(y,0);
coun=ptr-y-1;
r=y[coun]-48;
if(coun>1)
r=r+10*(y[coun-1]-48);
m=x[r%10];
n=7*(r/10);
m=(m+n)%10;
g<<m<<"\n";
}
f.close();
g.close();
return 0;
}