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 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
| program ChampionnatDeF1; {Degrève Sébastien 1TL1}
uses crt;
CONST Nbequipe = 3;
nMinc = 1;
nMaxc = 3;
TYPE pilote = record
point : integer;
nom : string;
end;
var p : array[1..(2*Nbequipe)] of pilote;
TYPE equipe = record
p : pilote;
point : integer;
nom : string;
end;
VAR tab : array[1..Nbequipe] of equipe;
i_pilote : array [1..(2*Nbequipe)] of integer;
i_constructeur : array [1..Nbequipe] of integer;
choix : char;
cpt : integer;
procedure encode_e;
var i,j: integer;
begin
ClrScr;
writeln('Encodages equipes et pilotes');
writeln('----------------------------');
writeln();
for i:=1 to Nbequipe do
begin
writeln('Entrez le nom du constructeur ',i);
readln(tab[i].nom);
for j := 1 to 2 do
begin;
writeln('pilote ',j);
readln(tab[j].p.nom);
end;
writeln();
end;
end;
procedure encode_p;
var i,j,a,t: integer;
begin
cpt := cpt+1;
writeln('Encodage point ');
writeln('----------------');
for i:=1 to Nbequipe do
begin
ClrScr;
writeln('Equipe : ',tab[i].nom);
for j := 1 to 2 do
begin;
writeln('pilote ',j,' ',tab[j].p.nom);
readln(t);
tab[j].p.point := tab[j].p.point + t;
end;
writeln();
end;
end;
procedure classement_c;
var i,j,tampon: integer;
begin
ClrScr;
writeln('Classement des constructeurs');
writeln('----------------------------');
writeln();
for i := 1 to Nbequipe do
begin
tab[i].point := tab[1].p.point + tab[2].p.point;
end;
if cpt > (nMINc) then
begin
if cpt < (nMAXc) then
begin
for i:=1 to Nbequipe-1 do
begin
for j:=i+1 to Nbequipe do
begin
if tab[i].point >tab[j].point then
begin
tampon := i_constructeur[i];
i_constructeur[i] := i_constructeur[j];
i_constructeur[j]:= tampon;
end;
end;
end;
for i:=1 to Nbequipe do
writeln(' ',i,'. ',tab[i_constructeur[i]].nom,' avec',tab[i_constructeur[i]].point);
end;
if cpt > (nMAXc) then writeln('Trop de courses championat non valide');
end;
if cpt < (nMINc) then writeln('Pas assez de de courses championat non valide');
readln;
end;
procedure classement_p;
var i,j,tampon: integer;
begin
ClrScr;
writeln('Classement des pilotes');
writeln('----------------------');
writeln();
if cpt > (nMINc) then
begin
if cpt < (nMAXc) then
begin
for i:=1 to ((2*Nbequipe)-1) do
begin
for j:=i+1 to (2*Nbequipe) do
begin
if tab[i].p.point >tab[j].p.point then
begin
tampon := i_pilote[i];
i_pilote[i] := i_pilote[j];
i_pilote[j]:= tampon;
end;
end;
end;
for i:=1 to Nbequipe do
writeln(' ',i,'. ',tab[i_pilote[i]].p.nom,' avec',tab[i_pilote[i]].p.point);
end;
if cpt > (nMAXc) then writeln('Trop de courses championnat non valide');
end;
if cpt < (nMINc) then writeln('Pas assez de courses championnat non valide');
readln;
end;
Procedure menu;
begin
writeln(' MENU CHAMPIONNAT F1');
writeln(' -------------------');
writeln();
writeln(' 1. Encodage equipe');
writeln(' 2. Encodage point course');
writeln(' 3. Classement constructeur');
writeln(' 4. Classement pilote');
writeln('');
writeln(' 0. quitter');
writeln('');
write(' choix :');
end;
begin
repeat
ClrScr;
menu;
readln(choix);
case choix of
'1' : begin
encode_e;
end;
'2' : begin
encode_p;
end;
'3' : begin
classement_c;
end;
'4' : begin
classement_p;
end;
end;
until choix = '0';
ClrScr;
writeln();
writeln('Good Bye');
readln;
end. |
Partager