Bonjour,
J'ai un petit problème dans le programme suivant dans la procédure tri.
Si qqn trouve, je suis preneur
******************************************************
program tri_nombres_par_extraction_ou_selection;
uses wincrt;
const nbre_elements = 10;
var tableau_nbres : array [1..nbre_elements] of Integer;
i : Byte;
{****************************************************}
Procedure Permutation(var a,b : Byte);
Var CaseTemp : Byte;
Begin
CaseTemp := tableau_nbres[a];
tableau_nbres[a] := tableau_nbres[b];
tableau_nbres[b] := CaseTemp;
End;
{****************************************************}
{****************************************************}
Procedure Affichage;
var i : Byte;
Begin
for i := 1 to nbre_elements do
write (tableau_nbres[i], ' ');
writeln;
End;
{****************************************************}
{****************************************************}
Function CherchePlusPetit(tableau_elements, debut : Integer) : integer;
var ValeurIndMin, j : integer;
Begin
ValeurIndMin := debut;
for j := debut+1 to nbre_elements do
if tableau_nbres[j] < tableau_nbres[ValeurIndMin] then
ValeurIndMin := j;
CherchePlusPetit := ValeurIndMin;
End;
{****************************************************}
{****************************************************}
Procedure Tri (tableau_nbres, nbre_elements : integer);
var i : byte;
Begin
for i:= 1 to nbre_elements-1 do
Begin
if tableau_nbres [i-1]>CherchePlusPetit(tableau_nbres, i, (nbre_elements-1)) then
permutation(tableau_nbres, i-1, CherchePlusPetit(tableau_nbres, i, (nbre_elements-1));
End;
End;
{****************************************************}
BEGIN
Randomize;
for i := 1 to nbre_elements do
tableau_nbres[i] := random(100);
Write ('Voici les nombres aléatoires choisis: ');
Affichage;
Writeln ;
Tri;
Write ('Voici les nombres choisis triés: ');
Affichage;
Writeln;
END.
Afficher la suite