type TIntArr = array of Integer; {极快的正整数排序函数} procedure IntSort(arr:TIntArr; low:Integer=0; high:Integer=-1; k:Cardinal=$80000000; c:Cardinal=1); var i,j,x: Integer; begin if high = -1 then high := Length(arr) -1; i := low; j := high; while (i < j) do begin while (arr[j] and k <> 0) and (i < j) do Dec(j); while (arr[i] and k = 0) and (i < j) do Inc(i); if i < j then begin x := arr[j]; arr[j] := arr[i]; arr[i] := x; end else begin if arr[j] and k <> 0 then Dec(i) else Inc(j); Break; end; end; if k > c then begin if low < i then IntSort(arr, low, i, k div 2); if j < high then IntSort(arr, j, high, k div 2); end; end;