Pagini recente » Cod sursa (job #3156378) | Cod sursa (job #890100) | Cod sursa (job #2708589) | Cod sursa (job #403264) | Cod sursa (job #178378)
Cod sursa(job #178378)
#include<fstream.h>
#include<iostream.h>
#include<math.h>
#include<stdio.h>
int main(void)
{
long int t,r,i,j,x[10],m,n,coun,h;
fstream f,g;
char y[105];
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;
f.getline(y,105);
for(i=1;i<=t;i++)
{
r=0;
for(j=0;j<105;j++)
y[j]='a';
f.getline(y,105);
coun=0;
while(y[coun]!='a')
coun++;
coun--;
r=y[coun-1]-48;
if(coun>1)
r=r+(y[coun-2]-48)*10;
m=x[r%10];
n=7*((r%100)/10);
m=(m+n)%10;
g<<m<<"\n";
}
f.close();
g.close();
return 0;
}