Pagini recente » Cod sursa (job #1658888) | Cod sursa (job #2249947) | Cod sursa (job #592946) | Cod sursa (job #2375754) | Cod sursa (job #1457402)
#include <fstream>
using namespace std;
ifstream fin("cifra.in");
ofstream fout("cifra.out");
int nr, i, x, v[200], total, numar;
char c;
int main()
{
fin >> numar;
fin.get();
for(i=1; i <= numar; i++)
{
fin.get(c);
x = 1;
while(c != '\n')
{
v[x] = c-'0';
x++;
fin.get(c);
}
x--;
nr = v[x-1]*10 + v[x];
total = (nr / 10) * 47;
nr %= 10;
if(v[x-1] % 2 == 0)
{
if(nr >= 1)
total += 1;
if(nr >= 2)
total += 4;
if(nr >= 3)
total += 7;
if(nr >= 4)
total += 6;
if(nr >= 5)
total += 5;
if(nr >= 6)
total += 6;
if(nr >= 7)
total += 3;
if(nr >= 8)
total += 6;
if(nr >= 9)
total += 9;
}
else
{
if(nr >= 1)
total += 1;
if(nr >= 2)
total += 6;
if(nr >= 3)
total += 3;
if(nr >= 4)
total += 6;
if(nr >= 5)
total += 5;
if(nr >= 6)
total += 6;
if(nr >= 7)
total += 7;
if(nr >= 8)
total += 4;
if(nr >= 9)
total += 9;
}
fout << total%10 << '\n';
}
}