random(1);~~就是产生一个小于1的随即数阿~~可不是一直为零吗?

解决方案 »

  1.   

    function Random [ ( Range: Integer) ];DescriptionRandom 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 range就是返回一个>=0并且<Range的数值~~
      

  2.   

    procedure TForm1.Button1Click(Sender: TObject);
    const
      cCount = 10000;
    var
      I: Integer;
      S: Integer;
    begin
      Randomize;
      S := 0;
      for I := 1 to cCount do
        if Round(Sqrt(Sqr(Random(cCount)) + Sqr(Random(cCount)))) <= cCount then Inc(S);
      Caption := FloatToStr(cCount / (S * 4));
    end;