time() srand() rand()
2010-08-13 10:13
225 查看
time()
返回系统当前时间,从1970年1月1日0时0分算起
如: temptime=time(NULL); // 可以写成 time(&temptime)
常用于随机数产生作为种子
如: srand((usigned) time(NULL));
又如:srand(time(&temptime) %60);
t = rand() % 52 //随机取0-52之间数
返回系统当前时间,从1970年1月1日0时0分算起
如: temptime=time(NULL); // 可以写成 time(&temptime)
常用于随机数产生作为种子
如: srand((usigned) time(NULL));
又如:srand(time(&temptime) %60);
t = rand() % 52 //随机取0-52之间数
相关文章推荐
- c语言中利用rand()time()srand()....产生随机数【4-5】猜数游戏
- srand((unsigned)time(NULL))和rand()
- rand()和srand((unsigned)time(NULL))产生的随机数有什么不同
- 关于srand(time(0)) rand() 的解释
- rand()和srand((unsigned)time(NULL))产生的随机数有什么不同http://blog.csdn.net/jinjingwen/article/details/6205537
- 关于srand(time(0)) rand() 的解释
- 数据结构学习(1) c语言中关于srand((unsigned)time(NULL))和rand的区别
- srand((unsigned)time(NULL))和rand()
- srand((unsigned)time(NULL))和rand的区别
- 随机数rand()必须结合srand(time(NULL))
- WEEK8晚第一题(升级版哦,每次运行都可以出现不同学号哦,耶!用srand(time(0))解决,不被rand()局限)
- 随机数rand()必须结合srand(time(NULL))
- 关于srand(time(0)) rand() 的解释
- 关于srand(time(0)) rand() 的解释
- c语言中关于srand((unsigned)time(NULL))和rand的区别
- rand()和srand((unsigned)time(NULL))产生的随机数有什么不同
- C++中随机函数rand()和srand()的用法以及time()的使用
- 关于srand(time(0)) rand() 的解释
- 关于srand(time(0)) rand() 的解释
- C++ 中的随即种子问题srand rand 涉及库 cstdlib ctime