Pagini recente » Cod sursa (job #1894402) | Cod sursa (job #2093095) | Cod sursa (job #1100410) | Cod sursa (job #2256895) | Cod sursa (job #1717477)
#include <iostream>
#include <string.h>
#include <fstream>
using namespace std;
ifstream f("cifra.in");
ofstream g("cifra.out");
int ult(unsigned n)
{
unsigned p,s=0,i,j;
for( i=1; i<=n; i++)
{
p=1;
for(j=1; j<=i; j++)
{
p*=i;
}
s+=p;
}
return s%10;
}
int cuv(char txt[])
{
return txt[strlen(txt) - 1] - '0';
}
int main()
{
unsigned T,i;
char txt[200][200];
f>>T;
for(i=1; i<=T; i++)
{
f>>txt[i];
}
for(i=1; i<=T; i++)
{
g<<ult(cuv(txt[i]))<<"\n";
}
}