Pagini recente » Cod sursa (job #2599778) | Cod sursa (job #2770276) | Cod sursa (job #3181089) | Cod sursa (job #378556) | Cod sursa (job #2390284)
#include <bits/stdc++.h>
#define Dim 102
using namespace std;
ifstream f("cifra.in");
ofstream g("cifra.out");
int T,ans,V[12],A[12];
char N[Dim];
int main()
{
V[1]=1; V[2]=4; V[3]=7; V[4]=6; V[5]=5; V[6]=6; V[7]=3; V[8]=6; V[9]=9;
A[1]=1; A[2]=6; A[3]=3; A[4]=6; A[5]=5; A[6]=6; A[7]=7; A[8]=4; A[9]=9;
f>>T; f.get();
for(int i=1;i<=T;i++)
{
ans=0;
f.get(N,Dim);
f.get();
int lg=strlen(N)-1;
char tup=N[lg-1];
int c1=atoi(&tup);
int ramas=atoi(&N[lg]);
ans+=c1+( (4*c1)%10 )+( (5*c1)%10 )+( (6*c1)%10 )+( (9*c1)%10 );
//cout<<N<<" "<<i<<" "<<c1<<" "<<ramas<<" "<<ans<<'\n';
for(int j=1;j<=ramas;j++)
{
if(c1%2==0) ans+=V[j];
else ans+=A[j];
}
ans%=10;
g<<ans<<'\n';
}
return 0;
}