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 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
   | Program Note_plongeurs;
 
const FileName = 'resultat.txt';
 
type Plongeurs = record
                    nom:  string;
                    plongeons: array [1..3] of array [1..7] of real;
                    coefficient: array[1..3] of real;
                    note: real;
                  end;
var competition : array [1..5] of Plongeurs;
 
 
procedure FillRecord(FileName: string);
var i,j,k : integer;
    f: Textfile;
    tampon:string;
    code:integer;
begin
   Assign(f,Filename); {associe le fichier à la variable f}
{$I-}
   Reset(f);
{$I+}
  if IOresult<>0 then
   begin
     writeln('Le fichier est introuvable ');
     readln;
     halt;
   end;
 
   while not EOF(F) do
   begin
     for i:=1 to 5 do {pour chaque plongeur}
     begin
       readln(f,competition[i].nom);
       for j:=1 to 3 do {pour chaque plongeons}
       begin
         readln(f,tampon);
         Val(tampon,competition[i].coefficient[j],code);
         for k:= 1 to 7 do {pour chaque note}
         begin
           readln(f,tampon);
           Val(tampon,competition[i].plongeons[j][k],code);
         end;
       end;
     end;
   end;
   close(F);
end;
 
procedure Calculnote;
var
minnote,maxnote,moyenne:real;
i,j,k:integer;
begin
     for i:=1 to 5 do {pour chaque plongeur}
     begin
     competition[i].note:=0;
       for j:=1 to 3 do {pour chaque plongeons}
       begin
       moyenne:=0;
       minnote:=10;
       maxnote:=0;
         for k:= 1 to 7 do {pour chaque note}
         begin
                if competition[i].plongeons[j][k]<minnote then
                 minnote:=competition[i].plongeons[j][k];
                if competition[i].plongeons[j][k]>maxnote then
                 maxnote:=competition[i].plongeons[j][k];
                moyenne:=moyenne +competition[i].plongeons[j][k];
 
         end;
         moyenne:=moyenne -minnote -maxnote;
         moyenne:=moyenne/5;
         moyenne:=moyenne*competition[i].coefficient[j];
         competition[i].note:= competition[i].note + moyenne;
       end;
        competition[i].note:= competition[i].note/3;
     end;
   end;
procedure trierplongeur;
var i,j,minj:integer;
    minx:plongeurs;
begin
        for i:= 1 to (5-1) do
        begin
                minj:=i;
                minx:= competition[i];
                For j:= (i+1) to 5 do
                begin
                        if( competition[j].note>minx.note) then
                        begin
                                minj:=j;
                                minx:= competition[j];
                        end;
                end;
                competition[minj]:=competition[i];
                competition[i]:=minx;
        end;
end;
 
 
procedure ShowCompetition;
var i,j,k : integer;
begin
  for i:=1 to 5 do  begin{pour chaque plongeur}
    writeln(competition[i].nom, '  (', competition[i].note:0:3, ')');
    for j:=1 to 3 do begin{pour chaque coefficient de plongeon}
      (*writeln(f,competition[i].plongeons[j]);*)
      for k:= 1 to 7 do begin{pour chaque note}
          write('    ', competition[i].plongeons[j][k]:0:2, ', ');
      end;
      writeln;
    end;
  end;
end;
 
begin
fillrecord(FileName);
calculnote;
trierplongeur;
Showcompetition;
readln;
end. | 
Partager