⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.~pas

📁 DELPHI 产生N个不同的随机数。 希望大家能用得上
💻 ~PAS
字号:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)

    Button1: TButton;


    procedure Button1Click(Sender: TObject);

  private
    { Private declarations }
  public
    { Public declarations }
   // MyArray : array of Integer;
   //procedure Rands1();
  end;
  MyArray = array of Integer;
var
  Form1: TForm1;
  a1: MyArray;
implementation

{$R *.dfm}

procedure Rands1(SizeA:integer);
var
  I, J, temp: Integer;
begin
SetLength(a1, SizeA);
  for I := 1 to SizeA do
  begin
    a1[I] := I;
  end;
  Randomize;
  for I := 1 to SizeA do
  begin
    J := Random(SizeA);
    if I <> J then
    begin
      temp := a1[J];
      a1[J] := a1[I];
      a1[I] := Temp;
    end;
  end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
  I: Integer;
  a:string;
begin
  Rands1(16);
  for I := 1 to 10 do
  begin
    //ShowMessage(IntToStr(a1[I]));
    a:=a +  inttostr(a1[I]) + ',';

  end;
  showmessage(a);
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -