Pagini recente » Cod sursa (job #1947843) | Cod sursa (job #108331) | Cod sursa (job #2339930) | Cod sursa (job #1335974) | Cod sursa (job #1415426)
#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;
}