uses crt;
var
f:Text;
Action,Inp_Type,Out_Type:Byte;
N:Byte;
FIO:string[25];
Birth_Date:string[10];
Course:Byte;
Year:word;
Marks:Array[1..3] of Byte;
Mmark:Real;
Procedure Inp_Date;
var i:Byte;
begin
writeln('Vvodite dannie o studentax:');
Repeat
Inc(N);
write(f,N:2,' ');
write('FIO: ');
readln(FIO);
write(f,FIO);
for i:=Length(FIO)+1 to 25 do write(f,' ');
write('Birth Date (dd.mm.yyyy): ');
readln(Birth_Date);
write(f,Birth_Date);
write('Course: ');
readln(Course);
write(f,Course:3);
write('Year of entry: ');
readln(Year);
write(f,Year:5);
Mmark:=0;
for i:=1 to 3 do
begin
write('Mark ',i,' = ');
readln(Marks[i]);
write(f,Marks[i]:4);
Mmark:=Mmark+Marks[i]/3;
end;
writeln(f,Mmark:7:2);
clrscr;
writeln ('ENTER-continue, ESC-quit');
Until readkey=#27;
end;
Procedure Out_Date(OT:Byte);
var i:byte; mmrk:real; C:Char;
begin
if OT=1 then mmrk:=0 else mmrk:=4;
Repeat
Read(f,N,C,FIO,Birth_Date,Course,Year);
for i:=1 to 3 do read(f,Marks[i]);
Readln(f,Mmark);
If Mmark>mmrk then
begin
write(N:2,' '+FIO);
for i:=Length(FIO)+1 to 25 do write(' ');
write(Birth_Date);
write(Course:3);
write(Year:5);
for i:=1 to 3 do
write(Marks[i]:4);
writeln(Mmark:7:2);
end;
Until EoF(f);
end;
BEGIN
clrscr;
Assign(f,'D:\data');
REPEAT
Writeln('Vyberite dejstvie:');
Writeln(' 1 - Vvod dannyh');
Writeln(' 2 - Vyvod rezultata');
Writeln(' 3 - Vykhod iz programmy');
Readln(Action);
If Action=1 then
begin
Writeln('Variant vvoda:');
Writeln(' 1 - Novyi spisok');
Writeln(' 2 - Prodoljit spisok');
Readln(Inp_Type);
if Inp_Type=1 then
begin
Rewrite(f);
N:=0;
end
else
begin
Reset(f);
repeat
Readln(f,N);
until EoF(f);
Close(f);
Append(f);
end;
Inp_Date;
Close(f);
end else
If Action=2 then
begin
Reset(f);
Writeln('Variant vyvoda:');
Writeln(' 1 - Vse studenty');
Writeln(' 2 - Polychayushchie stipendiyu');
Readln(Out_Type);
Out_Date(Out_Type);
Close(f);
end;
UNTIL Action=3;
END.