那位可以把36选7的代码发给我看看`要交作业了`还是弄不出来`谢谢了

解决方案 »

  1.   

    我的意思是用Delphi做个像福利彩票一样的`1到36的个数里随机抽取7的数字!!!
      

  2.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
    i,k:integer;
    begin
    randomize;
    for i:=0 to 100 do
    begin
    k:=random(36);
    if k=36 then
    showmessage(inttostr(k))else
    memo1.Lines.Add('No');
    end;
    end;
      

  3.   

    procedure TfrmMain.Button1Click(Sender: TObject);
    begin
      RandomGel6;
    end;
    procedure TfrmMain.RandomGel6;
    var
      I                 : Integer;
      SL                : TStringList;
      tmp               : Integer;
    begin
      Randomize;
      SL := TStringList.Create;
      try
        for I := 0 to 6 do
        begin
          while True do
          begin
            tmp := 1 + Random(36);
            if SL.IndexOf(IntToStr(tmp)) < 0 then
            begin
              SL.Append(IntToStr(tmp));
              Break;
            end;
          end;
        end;
        Memo1.Text := SL.Text;
      finally
        SL.Free;
      end;
    end;
      

  4.   

    unit uMain;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TfrmMain = class(TForm)
        Memo1: TMemo;
        Edit1: TEdit;
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
        procedure RandomGel6;
        procedure RandomGel1;
      public
        { Public declarations }
         tmpNumber: array [0..6] of Integer ;
      end;var
      frmMain           : TfrmMain;
    implementation{$R *.dfm}procedure TfrmMain.Button1Click(Sender: TObject);
    begin
      RandomGel6;
      RandomGel1;end;procedure TfrmMain.RandomGel1;
    begin
      Randomize;
      Edit1.Text :='特码是:'+IntToStr(tmpnumber[6]);
    end;procedure TfrmMain.RandomGel6;
    var
      I                 : Integer;
      SL                : TStringList;
      tmp               : Integer;
    begin
      Randomize;
      SL := TStringList.Create;
      try
        for I := 0 to 6 do
        begin
          while True do
          begin
            tmp := 1+Random(36);
            tmpNumber[i]:=tmp;
            if SL.IndexOf(IntToStr(tmp)) < 0 then
            begin
              SL.Append('第'+IntToStr(i+1)+'个号码是:'+IntToStr(tmp));
              Break;
            end;
          end;
        end;
        Memo1.Text := SL.Text;
      finally
        SL.Free;
      end;
    end;end.
      

  5.   

    procedure TfrmMain.RandomGel6; 
    var 
      Int36 array[1..36]of integer;
      i,j,Num:integer; 
      SL:string; 
      tmp: Integer; 
    begin 
      Randomize;
      for i:=1 to 36 do
        Int36 := i;
      Num:=36;
      for i := 1 to 7 do 
      begin 
        tmp := 1+Random(Num); 
        SL:=SL+inttostr(Int36[tmp]);
        for j:= tmp to Num-1 do
          Int36[j]:=Int36[j+1];
        dec(Num);//Num:=Num-1;
      end; 
      Memo1.Text := SL.Text;  
    end;36个球选出一个后停止,剩下35个球再转,得到第二个球,类推……