Pagini recente » Cod sursa (job #165557) | Cod sursa (job #2258374) | Istoria paginii runda/ada37/clasament | Cod sursa (job #1590438) | Cod sursa (job #940153)
Cod sursa(job #940153)
#include<fstream>
#include<string.h>
using namespace std;
int T, t, exp, rest, p, nr, i, aux, cif;
char c[105];
int u[21]={0, 1, 5, 2, 8, 3, 9, 2, 8, 7, 7, 8, 4, 7, 3, 8, 4, 1, 5, 4, 4};
ifstream f("cifra.in");
ofstream g("cifra.out");
int main()
{
f>>T;
for(;T--;)
{
f>>c;
t=strlen(c);
if(t>1) nr=(c[t-2]-'0')*10+(c[t-1]-'0');
else nr=c[t-1]-'0';
if(t>=2)
{
if(nr>=21)
{
aux=4*(nr/20)+u[nr%20];
g<<aux%10<<"\n";
}
else g<<u[nr]<<"\n";
}
else g<<u[nr]<<"\n";
}
return 0;
}