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
| program essai;
type nbre=array[1..10]of integer;
var deb,fin,indice,i,a:integer;
procedure quicksort(var limite,deb,fin:integer;tab:nbre);
var pivot,i,aux:integer;
begin
pivot:=tab[1];
limite:=fin;
while limite<>i do
begin
if tab[i]<pivot then
begin
tab[i-1]:=tab[i];
i:=i+1;
end;
if tab[i]>pivot then
begin
aux:=tab[i];
tab[i]:=tab[limite];
tab[limite]:=aux;
limite:=limite-1;
end;
end;
tab[i]:=pivot;
quicksort(limite-1,deb,tab);
quicksort(fin,limite+1,tab);
end;
begin
writeln('Entrez les nombres');
deb:=1;
fin:=1;
while tab[i]<=0 or i=10 do
begin
read(tab[i];
i:=i+1
fin:=fin+1
end;
for a:=1 to fin
end;
quicksort(tab,limite,deb,fin);
end. |
Partager