Pagini recente » Cod sursa (job #1527416) | Cod sursa (job #2650178) | Cod sursa (job #587492) | Cod sursa (job #1476530) | Cod sursa (job #1723509)
#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;
ifstream in("cifra.in");
ofstream out("cifra.out");
char c[105];
int main()
{
int n;
in >> n;
in.get();
while(n > 0)
{
in.getline(c, 105);
int lg = strlen(c);
if(lg == 1)
{
long long s = 0;
for(int i = 1; i <= c[0] - '0'; i++)
{
long long nr = 1;
for(int j = 1 ; j <=i; j++)
nr = (nr * i) % 10;
s += nr;
s = s % 10;
}
out << s << '\n';
}
else
{
if(c[lg - 1] == '0')
out << "7" << '\n';
else if(c[lg - 1] == '1')
out << "8" <<' \n';
else if(c[lg - 1] == '2')
out << "2" << '\n';
else if(c[lg - 1] == '3')
out << "9" << '\n';
else if(c[lg - 1] == '4')
out << "5" << '\n';
else if(c[lg - 1] == '5')
out << "0" << '\n';
else if(c[lg - 1] == '6')
out << "6" << '\n';
else if(c[lg - 1] == '7')
out << "9" << '\n';
else if(c[lg - 1] == '8')
out << "7" << '\n';
else
out << "8" << '\n';
}
n --;
}
return 0;
}