Cod sursa(job #561459)

Utilizator Breje_RaulRaul Breje Breje_Raul Data 20 martie 2011 14:48:25
Problema Cifra Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.63 kb
 uses math;
 var i,s,t,er,n,u:longint;
     x:string;
     c:extended;
procedure putere;
 begin
  for i:=1 to n do
   begin
    c:=power(i,i);
    str(c:4:0,x);
    delete(x,length(x)-1,1);
    val(x,u,er);
     if (u>1)and(u<9) then
      s:=s+u
                      else
      s:=s+u mod 10;
   end;
  if (s>0)and(s<9) then
   writeln(s)
                   else
   writeln(s mod 10);
   s:=0;
 end;
begin
 assign(input,'cifra.in');reset(input);
 assign(output,'cifra.out');rewrite(output);
 readln(t);
  while not eof(input) do
   begin
    readln(n);
    putere;
   end;
 close(input);
 close(output);
end.