Cod sursa(job #6096)

Utilizator vanila0406Ionescu Victor vanila0406 Data 17 ianuarie 2007 14:41:58
Problema Cifra Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 1.41 kb
program cifra;
var f,g:text;
        t:longint;
        v:array[1..101] of longint;


procedure iofile;
var uc,i,lc,plc,ln:longint;
        c:char;
begin
        assign(f,'cifra.in');
        reset(f);
        assign(g,'cifra.out');
        rewrite(g);
        readln(f,t);
        for i:=1 to t do
                begin
        ln:=0;
        while not eoln(f) do
                begin
                        inc(ln);
                        read(f,c);
                        v[ln]:=ord(c)-ord('0');
                end;
                readln(f);
        lc:=v[ln];
        uc:=0;
        if ln=1 then plc:=0 else
                plc:=v[ln-1];
        case plc of
                0:uc:=uc+0;
                1:uc:=uc+7;
                2:uc:=uc+4;
                3:uc:=uc+1;
                4:uc:=uc+8;
                5:uc:=uc+5;
                6:uc:=uc+2;
                7:uc:=uc+9;
                8:uc:=uc+6;
                9:uc:=uc+3;
        end;
        case lc of
                0:uc:=uc+0;
                1:uc:=uc+1;
                2:uc:=uc+5;
                3:uc:=uc+2;
                4:uc:=uc+8;
                5:uc:=uc+3;
                6:uc:=uc+9;
                7:uc:=uc+2;
                8:uc:=uc+8;
                9:uc:=uc+7;
        end;
        uc:=uc mod 10;
        writeln(g,uc);
        end;
        close(g);
end;

begin
        iofile;
end.