Код
Type
Student = record
Name: String[10];
Group: Integer;
Marks: Array[1..3] of 2..5;
End;
MyFile=File Of Student;
Var
Count:Array[1..3] Of Integer;
Data:Array[1..3,1..20] Of Student;
i,j,k:Integer;
f:MyFile;
Avg:Array[1..3] Of Double;
Begin
For i:=1 To 3 Do
Begin
WriteLn('Enter Count Of Students From Group #',i,' (0..20): ');
ReadLn(Count[i]);
For j:=1 To Count[i] Do
Begin
Write( 'Enter Name Of Student #',j,': ');
ReadLn(Data[i,j].Name);
Data[i,j].Group:=i;
For k:=1 To 3 Do
Begin
Write(' Enter Mark #',k,' (2..5): ');
ReadLn(Data[i,j].Marks[k])
End
End
End;
Assign(f,'Stud.Txt');
ReWrite(f);
For i:=1 To 3 Do
Begin
WriteLn(f,' Group #',i);
For j:=1 To Count[i] Do
Begin
Write(f,Data[i,j].Name,': ');
For k:=1 To 3 Do
Write(f,Data[i,j].Marks[k],' ');
WriteLn(f)
End
End;
Close(f);
For i:=1 To 3 Do
Begin
Avg[i]:=0;
For j:=1 To Count[i] Do
For k:=1 To 3 Do
Avg[i]:=Avg[i]+Data[i,j].Marks[k];
If Count[i]<>0 Then
Avg[i]:=Avg[i]/Count[i]
End;
k:=1;
If Avg[2]>Avg[1] Then
k:=2;
If (Avg[3]>Avg[2]) And (Avg[3]>Avg[1]) Then
k:=3;
WriteLn('Best Average Mark Is ',Avg[k],' In Following Group(s):');
For i:=1 To 3 Do
If Avg[i]=Avg[k] Then
WriteLn(i)
End.
Примерно так...