Cod sursa(job #791864)
| Utilizator | Data | 25 septembrie 2012 17:23:28 | |
|---|---|---|---|
| Problema | Cifra | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.51 kb |
#include<fstream>
#include<cstring>
using namespace std;
int t, fin, cif, d, v[10], i;
char s[101], c[5];
int main()
{
ifstream f("cifra.in");
ofstream h("cifra.out");
f>>t;
f.getline(c, 5);
v[0]=0;
v[1]=1;
v[2]=5;
v[3]=2;
v[4]=8;
v[5]=3;
v[6]=9;
v[7]=2;
v[8]=8;
v[9]=7;
for (i=1; i<=t; ++i)
{
fin=0;
f.getline(s, 101);
cif=int(s[strlen(s)-1])-48;
if (strlen(s)>1)
{
d=int(s[strlen(s)-2])-48;
fin=7*d;
fin=fin%10;
}
fin+=v[cif];
h<<fin<<'\n';
}
}
