Cod sursa(job #730544)

Utilizator LauraBBuf Laura LauraB Data 6 aprilie 2012 14:22:28
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.42 kb
#include <fstream>
#include <cmath>
#include <cstring>
using namespace std;

ifstream fin("cifra.in");
ofstream fout("cifra.out");

int main()
{
	int n, k = 1, s = 0;
	fin >> n;
	char j;
	for(int i = 1; i <= n; i++)
	{
		fin >> j;
		j = j - '0';
		k = 1;
		s = 0;
		while(k <= j)
		{
			s += (int)pow(double(k), double(k));
			k++;
		}
		fout << s % 10 << endl;
	}
	fin.close();
	fout.close();
	return 0;
}