實現原理
unit Unit
interface
uses
Windows
Dialogs
type
TForm
Button
Memo
procedure Button
procedure FormCreate(Sender: TObject);
end;
var
Form
implementation
{$R *
type
TIntArr = array of Integer;
{極快的正整數排序函數}
procedure IntSort(arr:TIntArr; low:Integer=
var
i
begin
if high =
i := low;
j := high;
while (i < j) do
begin
while (arr[j] and k <>
while (arr[i] and k =
if i < j then
begin
x := arr[j];
arr[j] := arr[i];
arr[i] := x;
end else begin
if arr[j] and k <>
Break;
end;
end;
if k > c then
begin
if low < i then IntSort(arr
if j < high then IntSort(arr
end;
end;
{測試}
procedure TForm
var
MyArr: TIntArr;
i: Integer;
t: Int
begin
SetLength(MyArr
for i := Low(MyArr) to High(MyArr) do MyArr[i] := Random(MaxInt);
t := GetTickCount;
IntSort(MyArr); //調用排序函數
Text := IntToStr(GetTickCount
Memo
for i :=
begin
if i mod
Memo
end;
end;
procedure TForm
begin
Memo
Memo
Memo
end;
From:http://tw.wingwit.com/Article/program/Delphi/201311/8435.html