DELPHI 里,我想在1,3,4,8,9这五个数里随机选出一个数,显示在EDIT1上。怎么做?

来源:百度知道 编辑:UC知道 时间:2024/05/30 11:15:13

var
Form1:TForm1;
a:array[1..5]of integer=(1,3,4,8,9);
procedure TForm1.Button1Click(Sender: TObject);
begin
edit1.Text:=inttostr(a[random(6)]);
end;

procedure TForm1.Button1Click(Sender:TObject);
var
i:integer;
begin
Randomize;
i=Random(4);
if i=0 then edit1.text:='1';
if i=1 then edit1.text:='3';
if i=2 then edit1.text:='4';
if i=3 then edit1.text:='8';
if i=4 then edit1.text:='9';
end;
想要5个选出的几率相同,只有这样写了