Textové súbory TEXT a číslo

Čítanie čísel

Zápis čísel

Formátovací parameter vo write

Úloha: Napíšte program, ktorý nájde maximum z celých čísel v súbore.

 

var t:textfile;
cislo,max:integer;
prazdny:boolean;
begin
Assignfile(t,'cislo.txt');
Reset(t);
prazdny:=true;
if not Seekeof(t) then begin
                                 read(t,max);
                                 prazdny:=false;
                               end;
while not Seekeof(t) do begin
                                    read(t,cislo);
                                    if cislo>max then max:=cislo;
                                  end;
closefile(t);
if not prazdny then Memo1.Lines.Add('Maximum z cisel v subore: '+inttostr(max))
                    else Memo1.Lines.Add('Subor je prazdny.');
end;

návrat