Written on 2008年12月5日 @ 00:05 | by spirit | Tags: delphi   | 浏览:

    Randomize 语句
初始化随机数生成器。如果不使用 Randomize,则第一次调用 Rndom 函数时,它将使用相同的数字作为种子值,随后使用最后生成的数值作为种子值。建议每次取随机值的时候,先用Randomize,再用random,因为Randomize是起初始化作用的。如果只用random,比如:随机取100次,你就会发现有很多都在一个比较接近的范围,使得随机行显得稍差!


Randomize procedure
 Initializes the random number generator with a random value.

Description

Randomize initializes the built-in random number generator with a random value (obtained from the system clock). The random number generator should be initialized by making a call to Randomize, or by assigning a value to RandSeed.

Do not combine the call to Randomize in a loop with calls to the Random function. Typically, Randomize is called only once, before all calls to Random.


若转载请注明出处: Spirit's Home
本文地址: http://www.7788sky.cn/post/delphi_randomize.html
  1. 1 Response to “Delphi的Randomize语句”

  2. By Yacca on 2008-12-5 10:59:15| http://www.eemir3.com

    纯精神支持了...

Post a Comment

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。