Cod sursa(job #735918)

Utilizator LauraBBuf Laura LauraB Data 17 aprilie 2012 15:32:19
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.48 kb
#include <fstream>
#include <cmath>
#include <cstring>
using namespace std;

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

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