怎么用c编写生成(0,1)均匀分布的随机数?
编写生成(0,1)均匀分布的随机数?下面这段程序是我在书上看的,但程序不全,是大概的,能否帮我看看。万分感谢啦~程序代码:
#define IADD 453806245 #define IMUL 314159269 #define MASK 2147483647 #define SCALE 0.4656612873e-9 int randSeedP = 17; real RandR () { randSeedP = (randSeedP * IMUL + IADD) & MASK; return (randSeedP * SCALE); } void VRand (VecR *p) { real s; s = 2. * M_PI * RandR (); p->x = cos (s); p->y = sin (s); }