Pagini recente » Cod sursa (job #2728493) | Cod sursa (job #2513858) | Cod sursa (job #874161) | Cod sursa (job #6001) | Cod sursa (job #27650)
Cod sursa(job #27650)
#include <fstream>
#include <string.h>
#include <math.h>
using namespace std;
ifstream f1("cifra.in");
ofstream f2("cifra.out");
int conv(string a)
{
int l, aux, i;
aux=0;
l=a.length();
for (i=0; i<=l-1; i++)
aux=aux*10+((int)a[i]-48);
return aux;
}
int main(void)
{
const short int uc[20]={1,4,7,6,5,6,3,6,9,0,1,6,3,6,5,6,7,4,9,0};
const short int s=4;
string n;
short int smnf, rasp=0;
int i, t, asdf;
f1>>t;
for (asdf=1; asdf<=t; asdf++)
{
rasp=0;
f1>>n;
n="0"+n;
smnf=conv(n.assign(n.end()-2, n.end()));
rasp=floor(smnf/20)*s;
for (i=0; i<(smnf%20); i++)
rasp+=uc[i];
f2<<rasp%10<<endl;
}
f1.close();
f2.close();
return 0;
}