标题:休息一下,发个自己拿来买双色球的代码耍,没技术含量,代码很乱,看了别骂我 ...
取消只看楼主
anthony634
Rank: 6Rank: 6
来 自:西南交大
等 级:贵宾
威 望:24
帖 子:653
专家分:10
注 册:2006-6-8
结帖率:100%
 问题点数:0 回复次数:0 
休息一下,发个自己拿来买双色球的代码耍,没技术含量,代码很乱,看了别骂我,谢谢
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]]
搜索更多相关主题的帖子: 含量 代码 技术 休息 
2008-04-18 20:11



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-209823-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.568761 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved