Cod sursa(job #700039)

Utilizator iu.ciocoiuIulian iu.ciocoiu Data 29 februarie 2012 23:03:25
Problema Cifra Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.94 kb
program cifra;
type vector=array[0..9] of 0..9;
var f,g:text;
    t,i,p,u,er:word;
    n,m:char;
    x1,x2:vector;

function suma (c:word):word;
var s,j:word;
begin
s:=0;
if (p mod 2=0) then for j:=0 to c do s:=s+x1[j]
               else for j:=0 to c do s:=s+x2[j];
suma:=s;
end;

begin
assign (f,'cifra.in'); reset (f);
assign (g,'cifra.out'); rewrite (g);
readln (f,t);
x1[0]:=0; x1[1]:=1; x1[2]:=4; x1[3]:=7; x1[4]:=6;
x1[5]:=5; x1[6]:=6; x1[7]:=3; x1[8]:=6; x1[9]:=9;
x2[0]:=0; x2[1]:=1; x2[2]:=6; x2[3]:=3; x2[4]:=6;
x2[5]:=5; x2[6]:=6; x2[7]:=7; x2[8]:=4; x2[9]:=9;
for i:=1 to t do
   begin read (f,n);
         while (not (eoln(f))) do begin m:=n;
                                        read (f,n);
                                  end;
         readln (f);
         //writeln (m,n);
         val (m,p,er);
         val (n,u,er);
         writeln (g,(7*p+suma(u)) mod 10);
   end;
close (f);
close (g);
end.