var I: Integer;
begin
Randomize;
for I := 1 to 50 do begin
{ Write to window at random locations }
Canvas.TextOut(Random(Width), Random(Height), 'Boo!');
end;
end;
begin
Randomize;
for I := 1 to 50 do begin
{ Write to window at random locations }
Canvas.TextOut(Random(Width), Random(Height), 'Boo!');
end;
end;
Random 产生的是随机整数,使用前请用Randomize过程初始化,否则可能不唯一;
RandG 产生的是随机Extended数,他们是Gauss分布的;
具体的详细信息请看Delphi 帮助
如
x:=Random(1000)
结果是 0<x<1000的随机数
如
x:=Random(1000)
结果是 0<=x<1000的随机数