📄 mainfrm.pas
字号:
unit MainFrm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
mmSrc: TMemo;
mmDest: TMemo;
Label1: TLabel;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses
RadixSort;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
const
CCompareNumCount = 1000;
CMax = 1000;
var
I: Integer;
oList: TList;
oRadixSort: TRadixSort;
nRandomNum: Integer;
nStartTime, nEndTime: Integer;
begin
mmSrc.Lines.Clear;
mmDest.Lines.Clear;
oList := TList.Create;
oRadixSort := TRadixSort.Create;
try
//Test1
oList.Add(Pointer(23));
oList.Add(Pointer(123));
oList.Add(Pointer(567));
oList.Add(Pointer(894));
//Test2
// for I := 0 to CCompareNumCount do
// begin
// nRandomNum := Random(CMax);
// oList.Add(Pointer(nRandomNum));
// mmSrc.Lines.Add(IntToStr(nRandomNum));
// end;
//基数排序
nStartTime := GetTickCount;
oRadixSort.RadixSort(oList, 10, 4);
nEndTime := GetTickCount;
ShowMessage(IntToStr((nEndTime - nStartTime) div 1000));
for I := 0 to oList.Count - 1 do
mmDest.Lines.Add(IntToStr(Integer(oList.Items[I])));
finally
oList.Free;
oRadixSort.Free;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -