Pagini recente » Cod sursa (job #2059956) | Cod sursa (job #1052891) | Cod sursa (job #1242644) | Cod sursa (job #3147592) | Cod sursa (job #178428)
Cod sursa(job #178428)
#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]=9;
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=9*(r/10);
m=(m+n)%10;
g<<m<<"\n";
}
f.close();
g.close();
return 0;
}