procedure TForm1.Button1Click(Sender: TObject);
Var
i:integer;
begin
Randomize;
For i:=1 to N do
ARR[i]:=Trunc(90*Random+10);
For i:=1 to N do
Edit1.text:=Edit1.text+Inttostr(ARR[i])+',';end;这里是自动生成两位数,可是Arr[i]:= Trunc(90*Random+10);这一句不明白.希望高手指点.
Var
i:integer;
begin
Randomize;
For i:=1 to N do
ARR[i]:=Trunc(90*Random+10);
For i:=1 to N do
Edit1.text:=Edit1.text+Inttostr(ARR[i])+',';end;这里是自动生成两位数,可是Arr[i]:= Trunc(90*Random+10);这一句不明白.希望高手指点.
90乘随机数再加10然后取整数部分
--Trunc 取整数部分
--Random 随机数
所以piaoqifeng(飘风)说的是对的!
Delphi syntax:function Random [ ( Range: Integer) ];DescriptionIn Delphi code, Random returns a random number within the range 0 <= X < Range. If Range is not specified, the result is a real-type random number within the range0 <= X < 1.To initialize the random number generator, add a single call Randomize or assign a value to the RandSeed variable before making any calls to Random.Note: Because the implementation of the Random function may change between compiler versions, we do not recommend using Random for encryption or other purposes that require reproducible sequences of pseudo-random numbers.