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
| Procedure TriABulles(Var Tab:Array Of Integer);
Var i,j,t:Integer;
Begin
For i:=Low(Tab) To High(Tab)-1 Do For j:=i+1 To High(Tab) Do If Tab[i]>Tab[j] Then
Begin
t:=Tab[i];
Tab[i]:=Tab[j];
Tab[j]:=t;
End;
End;
// Ou
Procedure QuickSort(Var Tab:Array Of Integer);
Var i,j,t:Integer;
Function Partition(m,n:Integer):Integer;
Var i,j,v:Integer;
Begin
v:=Tab[m];
i:=m-1;
j:=n+1;
While True Do
Begin
Repeat Dec(j) Until Tab[j]<=v;
Repeat Inc(i) Until Tab[i]>=v;
If (i<j)
Then Begin
t:=Tab[i];
Tab[i]:=Tab[j];
Tab[j]:=t;
End
Else Begin
Result:=j;
Exit;
End;
End;
End; |