Cod sursa(job #6098)

Utilizator vanila0406Ionescu Victor vanila0406 Data 17 ianuarie 2007 14:50:19
Problema Cifra Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 1.38 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:=0;
                1:uc:=7;
                2:uc:=4;
                3:uc:=1;
                4:uc:=8;
                5:uc:=5;
                6:uc:=2;
                7:uc:=9;
                8:uc:=6;
                9: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.