Создать базу данных самолетов- Pascal(Паскаль)

Создать файл baza.txt в каталоге с файлом программы

program dred9;
USES CRT;

TYPE
rec=record
n_rejsa:string;
marsh:string;
typeplane:string;
station:string;
price:real;
end;

VAR s: string;

procedure privet;
begin
WriteLn('/*** База данных самолетов ***/');
WriteLn;
WriteLn('Что вы хотите сделать?');
WriteLn('1 - показать все записи');
WriteLn('2 - Добавить записи');
WriteLn('3 - Поис по номеру Рейса');
WriteLn('0 - виход');
end;

procedure AddRecord(r:rec);
var f: text;
begin
assign(f, 'baza.txt');
append(f);
writeln(f,r.n_rejsa);
writeln(f,r.marsh);
writeln(f,r.typeplane);
writeln(f,r.station);
writeln(f,r.price);
close(f);
end;

procedure ReadRecord(s: string);
var f: text;
r:rec;
begin
clrscr;
assign(f, 'baza.txt');
reset(f);
writeln('====================');
while not EOF(f) do
begin
readln(f,r.n_rejsa);
readln(f,r.marsh);
readln(f,r.typeplane);
readln(f,r.station);
readln(f,r.price);
if (r.typeplane=s) or (s='') then 
writeln(r.n_rejsa:7, r.marsh:18, r.typeplane:10, r.station:10, r.price:7);
end;
writeln('====================');
close(f);
readln;
end;

procedure process(s: string);
var tip:string;
r: rec;
begin
if s='0' then halt(0) else
if s='1' then ReadRecord('') else
if s='2' then begin clrscr;
write('Номер рейса ');readln(r.n_rejsa);
write('Маршрут ');readln(r.marsh);
write('Тип самолета');readln(r.typeplane);
write('Остановка ');readln(r.station);
write('Цена ');readln(r.price);
AddRecord(r) end;
if s='3' then begin clrscr;write('тип=');readln(tip);ReadRecord(tip) end;
end;

BEGIN
repeat
clrscr;
privet;
read(s);
ReadRecord(s);
process(s);
writeln;
until false;
END.

Leave a Comment

9 + 1 =