program pr13;
uses crt;
type Tair = record
flight: string;
arr: string;
t_dep: string;
t_arr: string
end;
TairAr = array[1..20] of Tair;
procedure proc(table: TairAr; nt: byte;
var arr: TairAr; var na: byte; s2:string);
var i, j: byte;
zap: Tair;
begin
j:= 0;
for i:= 1 to nt do
if table[i].arr = s2 then begin
inc(j);
zap:= table[i];
with arr[j] do begin
flight:= zap.flight;
arr:= zap.arr;
t_dep:= zap.t_dep;
t_arr:=zap.t_arr;
end;
end;
na:= j;
end;
var
i, nt, na: byte;
table: TairAr;
arr: TairAr;
fl: file of Tair;
s,s2: string;
begin clrscr;
write('enter file name-> ');
readln(s);
assign(fl, s);
rewrite(fl);
i:=1;
while true do begin
with table[i] do begin
writeln(i,'-i flight:');
write('enter flight code -> '); readln(flight);
if flight = 'z' then break;
write('enter arrival destination -> ');
readln(arr);
write('enter departure time -> ');
readln(t_dep);
write('enter arrival time -> ');
readln(t_arr);
write(fl, table[i]);
inc(i);
end;
end;
nt:= i;
Write('search for town: ');
Readln(s2);
proc(table, nt, arr, na, s2);
writeln(':');
for i:= 1 to na do
with arr[i] do
writeln(flight:3, arr: 10, t_dep:5, t_arr:5);
close(fl);
readkey;
end.