Procedure QuickSort (var a : array[1..100] of integer;
Procedure Sort (L, R : byte);
Var i,j:byte;
TG, X: integer;
BEGIN
X:=A[(L+R) div 2];
i:=L;
j:=R;
repeat
while (a[i]<X) do inc (i);
while (a[j]>X) do dec (j);
if i<=j then
begin
c := A[i];
A[i] := A[j];
A[j] :=c;
inc(i);
dec(j);
end;
Until i>j;
if L < j then Sort (L,j);
if i < R then Sort (i,R);
END;
BEGIN
Sort(1,n);
END;
|