Pagini recente » Cod sursa (job #1621848) | Cod sursa (job #3032016) | Cod sursa (job #2483060) | Cod sursa (job #1656589) | Cod sursa (job #1121440)
#include<fstream>
#include<string.h>
using namespace std;
int main()
{
ifstream f;
f.open("cifra.in");
ofstream g;
g.open("cifra.out");
int n, aux=0, i, j, k, l,s=0;
char nr[105];
f>>n;
f.getline(nr,10);
for(j=1;j<=n;j++)
{
f.getline(nr,105);
//f.get();
if(strlen(nr)==1) aux=nr[0]-'0';
else aux=10*(nr[strlen(nr)-2]-'0')+nr[strlen(nr)-1]-'0';
for(k=1;k<=aux;k++)
// s=s+fact(k,k);
{
l=1;
if(k%4==0)
l=k*k*k*k;
else
for(i=1;i<=k%4;i++)
l=l*k;
s+=l%10;
}
g<<s%10<<endl;
s=0;
}
return 0;
}