摘要: This section describes the random number functions that are part of the ISO C standard.To use these facilities, you should include the header file`stdlib.h'in your program.Macro:intRAND_MAXThe value of this macro is an integer constant representing the largest value therandfunction can return. I 阅读全文
posted @ 2014-01-21 20:49 小小鑫 阅读(494) 评论(0) 推荐(0) 编辑
摘要: 标准库(被包含于中)提供两个帮助生成伪随机数的函数:函数一:intrand(void);从srand(seed)中指定的seed开始,返回一个[seed,RAND_MAX(0x7fff))间的随机整数。函数二:voidsrand(unsignedseed);参数seed是rand()的种子,用来初始化rand()的起始值。可以认为rand()在每次被调用的时候,它会查看:1) 如果用户在此之前调用过srand(seed),给seed指定了一个值,那么它会自动调用srand(seed)一次来初始化它的起始值。2) 如果用户在此之前没有调用过srand(seed),它会自动调用srand(1)一次 阅读全文
posted @ 2014-01-21 20:16 小小鑫 阅读(2090) 评论(4) 推荐(0) 编辑