Subor - meno, vek, plat, výpis (Zadanie 24)

program subory; uses crt; var meno:array [1..100] of string; vek,plat:array [1..100] of integer; telcislo:array [1..100] of string; i,j,n,s1,s2:integer;x1,x2:real; subor:text;max:integer; begin assign(subor,'text.txt'); rewrite(subor); clrscr; n:=1; i:=1; s1:=0;s2:=0; writeln('AK CHCES SKONCIT STLAC - N'); repeat writeln('ZADAJ MENO: ');readln(meno[i]); writeln('ZADAJ VEK: ');readln(vek[i]); writeln('ZADAJ PLAT');readln(plat[i]); writeln('ZADAJ TEL CISLO');readln(telcislo[i]); write(subor,'MENO PRACOVNIKA:',meno[i],' '); write(subor,'VEK PRACOVNIKA: ',vek[i],' '); write(subor,'PLAT PRACOVNIKA: ',plat[i],' '); write(subor,'TEL CISLO: ',telcislo[i],' '); s1:=s1+plat[i]; inc(n);inc(i); until upcase(readkey)='N'; n:=n-1; writeln; for i:=1 to n do begin writeln('EVIDENCNE CISLO PRACOVNIKA: ',i); writeln('meno: ',meno[i]); writeln('vek: ',vek[i]); writeln('plat: ',plat[i]); writeln('tel cislo: ',telcislo[i]); writeln; end; max:=vek[1];s2:=1; for i:=1 to n do if max<vek[i] then begin max:=vek[i];s2:=i;end; writeln('NAJSTARSI PRACOVNIK JE: '); writeln(meno[s2]); writeln('vek: ',max); writeln('plat: ',plat[s2]); writeln('tel cislo: ',telcislo[s2]); writeln; x1:=s1 div n; writeln ('PRIEMERNY PLAT JE ',x1:4:2); writeln ('NA VYPLATU JE POTREBNYCH ',s1,' EUR'); close(subor); readln; end.