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);这一句不明白.希望高手指点.

解决方案 »

  1.   

    Arr[i]:= Trunc(90*Random+10);
    90乘随机数再加10然后取整数部分
      

  2.   

    Arr[i]:= Trunc(90*Random+10);
    --Trunc  取整数部分
    --Random 随机数
      

  3.   

    Trunc(90*Random+10)就保证结果是两位数了
      

  4.   

    哈,random不给参数出来的值是小于1的!
    所以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.