program quicksort; { QuickSort example part of Free Pascal distribution modified by Daniel Scharstein 9/22/99, 2/23/2009 } const max = 5000000; type tlist = array[1..max] of longint; procedure qsort(var a : tlist); procedure sort(l, r: longint); { nested procedure } var i, j, x, y : longint; begin i := l; j := r; x := a[(l+r) div 2]; repeat while a[i]j) then begin y := a[i]; a[i] := a[j]; a[j] := y; inc(i); j := j-1; end; until i>j; if l