program quick; {$APPTYPE CONSOLE} Var A : array[1..10000000] of integer; n: integer; i: integer; Procedure Swap(i, j : Integer); Var b : integer; Begin b := a[i]; a[i] := a[j]; a[j] := b End; Procedure Hoare(L, R : Integer); Var left, right : Integer; x : integer; Begin If L < R then begin x := A[(L + R) div 2]; left := L; right := R ; Repeat While A[left] < x do left := left + 1; While A[right] > x do right:=right - 1; If left <= right then begin Swap(left, right); left := left + 1; right := right - 1; end until left > right; Hoare(L, right); Hoare(left, R) end End; Begin randomize; readln(n); for i:=1 to n do begin a[i]:=random(100); write(a[i], ' '); end; Hoare(1, n); writeln; for i:=1 to n do write(a[i], ' '); writeln('ok'); readln; readln; End.