休息一下,发个自己拿来买双色球的代码耍,没技术含量,代码很乱,看了别骂我,谢谢
unit Unit1;interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
btnLucky: TButton;
Memo1: TMemo;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Edit7: TEdit;
lblMin: TLabel;
lblMax: TLabel;
lblBackMax: TLabel;
lblCreateNum: TLabel;
lblBaseSeed: TLabel;
lblFrontNum: TLabel;
lblBackNum: TLabel;
procedure btnLuckyClick(Sender: TObject);
private
{ Private declarations }
fMin, fMax, fBackMax: Integer;
fFornt, fBack: Integer;
function getRandomStr(const aBaseSeed: TLargeInteger): string;
public
{ Public declarations }
procedure AfterConstruction(); override;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TForm1 }
procedure TForm1.AfterConstruction;
begin
inherited;
fMin := 0;
fMax := 0;
fFornt := 6;
fBack := 1;
fBackMax := 16;
Edit1.Text := '1';
Edit2.Text := '36';
Edit3.Text := '1';
Edit4.Text := '6';
Edit5.Text := '1';
Edit6.Text := '16';
Edit7.Text := '20080418';
end;
function TForm1.getRandomStr(const aBaseSeed: TLargeInteger): string;
var
I: Integer;
aTrueBaseSeed: TLargeInteger;
aRandomVale: TLargeInteger;
resultStr: string;
counter: TLargeInteger;
aList: TStringList;
begin
Randomize;
aList := TStringList.Create;
aList.Sorted := True;
for I := 0 to fFornt do
begin
if QueryPerformanceCounter(counter) then
begin
aTrueBaseSeed := Counter + aBaseSeed;
end
else
begin
aTrueBaseSeed := GetTickCount + aBaseSeed;
end;
RandSeed := aTrueBaseSeed mod MaxInt;
aRandomVale := fMin + Random(fMax);
aList.Add(IntToStr(aRandomVale));
end;
for I := 0 to aList.Count - 1 do
begin
resultStr := resultStr + ' ' + aList[i];
end;
aList.Clear();
for I := 0 to fBack - 1 do
begin
if QueryPerformanceCounter(counter) then
begin
aTrueBaseSeed := Counter + aBaseSeed;
end
else
begin
aTrueBaseSeed := GetTickCount + aBaseSeed;
end;
RandSeed := aTrueBaseSeed mod MaxInt;
aRandomVale := fMin + Random(fBackMax);
aList.Add(IntToStr(aRandomVale));
end;
for I := 0 to aList.Count - 1 do
begin
resultStr := resultStr + '+' + aList[i];
end;
aList.Clear();
Result := Trim(resultStr);
end;
procedure TForm1.btnLuckyClick(Sender: TObject);
var
aCreateNum: Cardinal;
I: Integer;
fBaseSeed: Integer;
begin
aCreateNum := StrToIntDef(Edit3.Text, 5); // 注数
fMin := StrToIntDef(Edit1.Text, 0); // 前去最小
fMax := StrToIntDef(Edit2.Text, 36); // 后区最大
fFornt := StrToIntDef(Edit4.Text, 6); // 前去个数
fBack := StrToIntDef(Edit5.Text, 1); // 后区个数
fBackMax := StrToIntDef(Edit6.Text, 16); // 后区最大
fBaseSeed := StrToIntDef(Edit7.Text, 20080418); // 基种
Self.Caption := IntToStr(fBaseSeed);
for I := 0 to aCreateNum - 1 do
begin
Memo1.Lines.Add(getRandomStr(fBaseSeed));
end;
end;
end.
[[it] 本帖最后由 anthony634 于 2008-4-18 21:45 编辑 [/it]]