Cod sursa(job #212510)

Utilizator zizuZidaru Stefan zizu Data 5 octombrie 2008 19:13:22
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.42 kb
#include<iostream.h>
#include<fstream.h>
#include<math.h>
main()
{
	ifstream f1;
	f1.open("cifra.in");
	int t,n,i,k,f=0,x,y,s=0;
	f1>>t;
	ofstream f2;
	f2.open("cifra.out");
	for(i=0;i<t;i++)
	{
		 f1>>n;
		 f=n;
		 for(x=1;x<=f;x++)
		 {
			y=x;
			for(k=1;k<x;k++)
			{
				 y=y*x;
				 if(y>=10) y=y%10;
			}
			s=s+y;
         if(s>=10) s=s%10;

		 }
			f2<<s<<endl;
			s=0;

	}
return 0;
}