版本1和2间的区别
于2007-07-19 08:44:42修订的的版本1
大小: 756
编辑: czk
备注:
于2007-07-19 08:48:10修订的的版本2
大小: 782
编辑: czk
备注:
删除的内容标记成这样。 加入的内容标记成这样。
行号 1: 行号 1:
[[Navigation(slides)]]

Navigation(slides)

7.8.7 Random Number generation

The function rand() computes a sequence of pseudo-random integers in the range zero to RAND_MAX, which is defined in <stdlib.h>. One way to produce random floating-point numbers greater than or equal to zero but less than one is

   #define frand() ((double) rand() / (RAND_MAX+1.0))

(If your library already provides a function for floating-point random numbers, it is likely to have better statistical properties than this one.)

The function srand(unsigned) sets the seed for rand. The portable implementation of rand and srand suggested by the standard appears in Section 2.7.

Exercise 7-9. Functions like isupper can be implemented to save space or to save time. Explore both possibilities.

TCPL/7.8.7_Random_Number_generation (2008-02-23 15:37:07由localhost编辑)

ch3n2k.com | Copyright (c) 2004-2020 czk.