Cod sursa(job #175228)

Utilizator llobyLodoaba Mihai lloby Data 9 aprilie 2008 18:37:23
Problema Cifra Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.68 kb
Program en;

var s: string;
    n,m,e: longint;
    v,c: array[0..9]  of integer;
    t,f: text;
begin
   v[0]:=0; c[0]:=0;
   v[1]:=1; c[1]:=7;
   v[2]:=5; c[2]:=4;
   v[3]:=2; c[3]:=1;
   v[4]:=8; c[4]:=8;
   v[5]:=3; c[5]:=5;
   v[6]:=9; c[6]:=2;
   v[7]:=2; c[7]:=9;
   v[8]:=8; c[8]:=6;
   v[9]:=7; c[9]:=3;
   assign(t,'cifra.in'); reset(t);
   assign(f,'cifra.out'); rewrite(f);
   readln(t);
   while not eof(t) do
     begin
       readln(t,s);
       n:=0;
       m:=0;
       val(s[length(s)-1],m,e);
       if e=0 then
         n:=c[m];
       val(s[length(s)],m,e);
       n:=n+v[m];
       writeln(f,n mod 10);
     end;
   close(t);
   close(f);
end.