Accueil     Soft. MacOSX     Soft. MacOS/PC     PHP     Python     ROMS GBA     TP d'info     DBZ-GT     Martingales     Galeries     Liens     @  

Exercice 3

program tri_bulle;
var
i, j, k, p, dim, echange: integer;
t: array[1..500] of integer;

function rand (minimum, maximum: integer): integer;
begin
rand := minimum + Abs(Random) mod (maximum - minimum + 1);
end;
{ Fin de la fonction 'rand' }

begin
writeln('Tri croissant par bulle d''un tableau.');
writeln(' Affichage des étapes du tri.');
writeln(' http://www.Software-DS.com');

dim := 20;
{ dimension du tableau fixe a 20 de maniere arbitraire. }
for i := 1 to dim do
t[i] := rand(50, 500);
{ on remplit aletoirement le tableau. }

writeln('Le tri par bulle commence:');
for i := 1 to dim do
write(t[i] : 0, ',');
writeln;
k := dim;
j := dim;
repeat
echange := 0;
j := dim;
repeat
if (t[j] < t[j - 1]) then
begin
p := t[j];
t[j] := t[j - 1];
t[j - 1] := p;
for i := 1 to dim do
{ permet d'afficher les etapes intermediares }
write(t[i] : 2, ','); { permet d'afficher les etapes intermediares }
writeln; { permet d'afficher les etapes intermediares }
echange := 1;
end;
j := j - 1;
until (j = (dim - k));
k := k - 1;
until ((k = 1) or (echange = 0));
writeln;
writeln('©2001 All Rights Reserved to http://www.Software-DS.com 09/10/01');
{ ©2001 All Rights Reserved to http://www.Software-DS.com 09/10/01 }
end.





Haut de la page - Page précédente - Page générée en 0.03261 sec.
Recherche personnalisée
 

1843965 visiteurs.   ©2001-2023 All Rights Reserved to Software-DS.com
Made with a mac  
Confidentialité