{
1. Generovani nahodneho cisla
2. Vypsani cisla
3. Soucet 2 cisel -> vysledek cislo
}
{vlastni konstanta pro delku pole}
uses crt;

const delkapole=13;
      delkapolejedna=delkapole+1;

{vlastni datovy typ}
type cisla=array [1..delkapole] of byte;
     cislajedna=array [1..delkapolejedna] of byte;

{deklarace globlanich promennych}
var z: char;
    a,b: cisla;
    soucet_cisel: cislajedna;
    i:integer;

{1. generovani nahodneho cisla}
procedure nahodnecislo(var cislo:cisla);
var i:integer;
begin
     for i:=1 to delkapole do
         cislo[i]:=random(10);
end;

{2. vypsani cisla}
procedure vypiscislo(var cislo:cisla);
var i:integer;
begin
     for i:=1 to delkapole do
         write(cislo[i]);
     writeln;
end;

{3. soucet cisel}
procedure secticisla(var cislo:cislajedna);
var i,mezisoucet,prenos:integer;
begin
     for i:=delkapolejedna downto 1 do
         begin
              if i > 1 then mezisoucet:=0
              else mezisoucet:=prenos;
              if i-1 > 0 then
                 begin
                      mezisoucet:=a[i-1]+b[i-1];
                      prenos:=0;
                 end;
              if mezisoucet > 9 then
                 begin
                      prenos:=mezisoucet div 10;
                      a[i-2]:=a[i-2]+prenos;
                      mezisoucet:=mezisoucet mod 10;
                 end;
              cislo[i]:=mezisoucet;
         end;
     for i:=1 to delkapolejedna do
         write(cislo[i]);
     writeln;
end;

begin
repeat
clrscr;
writeln('Trtkal 2008 - http://fei.trtkal.net');
writeln('-----------------------------------');
begin
     randomize;
     nahodnecislo(a);
     nahodnecislo(b);
     write('Vypsane cislo a:      ');vypiscislo(a);
     write('Vypsane cislo b:      ');vypiscislo(b);
     for i:=1 to delkapolejedna do soucet_cisel[i]:=0;
     write('Soucet techto cisel: ');secticisla(soucet_cisel);
end;
writeln('-----------------------------------');
write('Opakovat a/n: ');readln(z);
until (z='n');
end.