Pagini recente » Cod sursa (job #643692) | Cod sursa (job #327155) | Cod sursa (job #2406371) | Borderou de evaluare (job #287029) | Cod sursa (job #2392360)
//
// main.cpp
// Alex
//
// Created by Hurjui Alexandru Mihai on 02/11/2018.
// Copyright © 2018 Hurjui Alexandru Mihai. All rights reserved.
//
#include <fstream>
using namespace std;
ifstream fin("cifra.in");
ofstream fout("cifra.out");
int main()
{
char x[101];
int t, i, nr;
int a[101];
for (i = 1; i<=100; i++)
{
if (i%10 == 1)
a[i] = 1;
else if (i%10 == 2)
{
if (i% 4 == 0)
a[i] = 6;
else
a[i] = 4;
}
else if (i%10 == 3)
{
if (i%4 == 1)
a[i] = 3;
else
a[i] = 7;
}
else if (i%10 == 4)
a[i] = 6;
else if (i%10 == 5)
a[i] = 5;
else if (i%10 == 6)
a[i] = 6;
else if (i%10 == 7)
{
if (i%4 == 1)
a[i] = 7;
else if (i%4 == 3)
a[i] = 3;
}
else if (i%10 == 8)
{
if (i%4==0)
a[i] = 6;
else
a[i] = 4;
}
else if (i%10 == 9)
a[i] = 9;
else if (i%10 == 0)
a[i] = 0;
}
a[0] = 0;
for (i = 1; i<=100; i++)
a[i] = (a[i-1] + a[i])%10;
fin >> t;
for (i = 1; i<=t; i++)
{
fin >> x;
if (strlen(x) > 1)
nr = (x[strlen(x)-2]-48)*10 + x[strlen(x)-1]-48;
else
nr = x[strlen(x)-1]-48;
fout << a[nr] << '\n';
}
return 0;
}