| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- CONST
- NScores = 5;
- NPupils = 8;
- type
- TScores = array [1..NScores] of 1..5;
- TPupil = record
- Name : string[30];
- Marks : TScores;
- Score : Word;
- end;
- var
- Pupils : array [1..NPupils] of TPupil;
- Temp : TPupil;
- Last : array [1..NPupils] of Byte;
- i,j : byte;
- begin
- Assign(Input,'2.txt');
- {$I-}
- Reset(Input);
- {$I+}
- If IOResult <> 0 then
- begin
- WriteLn('Error opening input file!');
- Halt(200);
- end;
- FillChar(Last,0,NPupils);
- for i := 1 to NPupils do
- with Pupils[i] do
- begin
- Read(Name);
- Score := 0;
- For j := 1 to NScores do
- begin
- Read(Marks[j]);
- Inc(Score,Marks[j]);
- if Marks[j] <= 2 then Inc(Last[i]);
- end;
- ReadLn;
- end;
- close(Input);
- for i := 1 to NPupils-1 do
- for j:= i+1 to NPupils do
- if Pupils[j].Score > Pupils[i].Score then
- begin
- Temp := Pupils[j];
- Pupils[j] := Pupils[i];
- Pupils[i] := Temp;
- end;
- Assign(Output,'Sorted.txt');
- Rewrite(output);
- WriteLn(' Результаты экзаменов ');
- WriteLn(' студенты отсортированы в порядке убывания успеваемости');
- for i := 1 to NPupils do
- begin
- Write(Pupils[i].Name);
- For j := 1 to NScores do
- Write(Pupils[i].Marks[j],' ');
- WriteLn;
- end;
- close(Output);
- Assign(OutPut,'exclude.txt');
- Rewrite(OutPut);
- WriteLn(' Список студентов, представленных на отчисление: ');
- for i := 1 to NPupils do
- if Last[i] > 1 then
- WriteLn(Pupils[i].Name);
- Close(OutPut);
- end.
|