uses crt type listPeople record number integer surname string averageM

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
uses crt;
type listPeople = record
number:integer;
surname:string;
averageMark:real;
subject : record
highermath:integer;
assemblers:integer;
cpp:integer;
physics:integer;
pascal:integer;
end;
end;
var f,f1:file of listPeople;
nameFile:string;
{------------------------------------------------------------}
procedure initRecord;
var i,k:integer;
list:listPeople;
s:string;
begin
assign(f,'list.txt');
rewrite(f);
randomize;
write('Введите количество студентов: ');
readln(k);
for i:=1 to k do
begin
list.number:=i;
write('Введите студента №',i,': ');
readln(list.surname);
with list.subject do
begin
highermath:=random(4)+2;
assemblers:=random(4)+2;
cpp:=random(4)+2;
physics:=random(4)+2;
pascal:=random(4)+2;
end;
write(f,list);
end;
close(f);
end;
procedure putInFile(var f:text);
{------------------------------------------------------------}
procedure printRecord(nameFile:string);
var i:integer;
list:listPeople;
begin
assign(f,nameFile);
reset(f);
i:=0;
writeln('+----------------++--------+-----------+------------+-----+---------+');
writeln('| Имя || pascal | assembler | Вышка | С++ | Физика |');
writeln('+----------------++--------+-----------+------------+-----+---------+');
while not eof(f) do
begin
seek(f,i);
read(f,list);
write('| ',list.surname: 14,' || ');
write(list.subject.pascal:3,' |');
write(list.subject.assemblers:5,' |');
write(list.subject.highermath:6,' |');
write(list.subject.cpp:3,' |');
write(list.subject.physics:5,' |'); writeln;
i:=i+1;
end;
writeln('+----------------++--------+-----------+------------+-----+---------+');
close(f);
end;
{------------------------------------------------------------}
procedure whoExpel(nameFile:string;nameFileExpel:string);
var i:integer;
list:listPeople;
begin
assign(f,nameFile);
assign(f1,nameFileExpel);
reset(f);
rewrite(f1);
i:=0;
while not eof(f) do
begin
seek(f,i);
read(f,list);
if((list.subject.highermath = 2) or
(list.subject.pascal = 2) or
(list.subject.assemblers = 2) or
(list.subject.cpp = 2) or
(list.subject.physics = 2)) then
write(f1,list);
inc(i);
end;
close(f);
writeln('+----------------++--------+-----------+------------+-----+---------+');
end;
{------------------------------------------------------------}
Begin
clrscr;
initRecord;
textbackground(1);
writeln('Список группи ТВ-81');
printRecord('list.txt');
whoExpel('list.txt','exlist.txt');
writeln('Список отчисленных в ТВ-81');
printRecord('exList.txt');
readkey;
End.