problème tri par sélection
Bonjour,
Alors voila j'ai essayer de faire un tri par sélection et je ne comprend pas pourquoi il ne marche pas, pourtant quand je le déroule à la main sa marche:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| tri_selection := proc(T::array(integer))::array(integer);
> local max, i, tmp::integer;
> while taille(T) <> 1 do
> max := 1;
> for i from 2 to taille(T) do
> if T[i] > T[max] then
> max := i;
> end if;
> end do;
> if max <> taille(T) then
> tmp := T[taille(T)];
> T[taille(T)] := T[max];
> T[max] := tmp;
> end if;
> taille(T) := taille(T)-1;
> end do;
> return eval(T);
> end proc; |
Merci bien:)