请教c++中的随机函数如何使用;(10分)

  • 主题发起人 lhlh_0_0
  • 开始时间
L

lhlh_0_0

Unregistered / Unconfirmed
GUEST, unregistred user!
请教c++中的随机函数如何使用,取值在0-1之间;
 
srand( (unsigned long)time( NULL ) );
int i=rand() % 2;
 
srand( (unsigned long)time( NULL ) );
double num = 1.0 * rand() /RAND_MAX;
 
多人接受答案了。
 
顶部