На основе экзаменационной ведомости включающей фамилии студентов и дисциплины (математика, физика, программирование, история), подсчитать средний балл для каждого студента и вывести на печать ведомость в порядке невозрастания среднего балла — Pascal(Паскаль)

uses crt;
const n=4;
type student=record
      name:string;
      math,phy,prog,hyst:byte;
      sr:real;
     end;
var x:array[1..n] of student;
    i:byte;
 
procedure Sort;
var i,imin,j:integer;
    tmp:student;
begin
for i:=1 to n-1 do
 begin
  imin:=i;
  for j:=i+1 to n do
   if x[j].sr>x[imin].sr then
    imin:=j;
  if imin<>i then
   begin
    tmp:=x[i];
    x[i]:=x[imin];
    x[imin]:=tmp;
   end;
 end;
end;
 
begin
ClrScr;
Writeln('Zapolnyte tablcy: ');
for i:=1 to n do
 with x[i] do
  begin
   Write(' Name: ');
   Readln(name);
   Write(' Math: ');
   Readln(math);
   Write(' Phy: ');
   Readln(phy);
   Write(' Prog: ');
   Readln(prog);
   Write(' Hyst: ');
   Readln(hyst);
  end;
x[i].sr:=0;
for i:=1 to n do
 x[i].sr:=x[i].math+x[i].phy+x[i].prog+x[i].hyst;
Sort;
Writeln('Table: ');
Writeln('---------------------------------------------------');
Writeln('|  Name  | Math | Phy | Prog | Hyst ||  Sr.Ball  ||');
Writeln('---------------------------------------------------');
for i:=1 to n do
 Writeln('|',x[i].name:8,'|',x[i].math:6,'|',x[i].phy:5,'|',
         x[i].prog:6,'|',x[i].hyst:6,'||',x[i].sr/4:11:1,'||');
Writeln('---------------------------------------------------');
Readln;
end.

Leave a Comment

+ 55 = 57