Pagini recente » Cod sursa (job #2488985) | Cod sursa (job #2683432) | Cod sursa (job #2760891) | Cod sursa (job #1227614) | Cod sursa (job #1415431)
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
ifstream f("cifra.in");
ofstream g("cifra.out");
int t,i,n,s;
void citire()
{
f>>t;
for(i=1;i<=t;i++)
f>>i;
}
int ultima_cifra(int x)
{
if(x>=0 && x<=9)
return x;
else
return x%10;
}
void generare()
{int j;
s=0;
for(j=1;j<=i;j++)
s=s+pow(j,j);
g<<ultima_cifra(s)<<endl;
}
int main()
{
citire();
for(i=1;i<=t;i++)
generare();
f.close();
g.close();
return 0;
}