C++产生随机数示例
C++产生随机数示例
C++产生随机数示例
#include <iostream>
#include <cstdlib>
#include <ctime>
using std::cout;
using std::endl;
int main(void){
//使用默认种子值产生随机数,每次产生的都一样
cout << rand() << " " << rand() << " " << rand() << endl;
//使用新种子产生随机数,每次都不一样
srand((unsigned int)time(0));
cout << rand() << " " << rand() << " " << rand() << endl;
return 0;
}
如何用C++产生随机数
C++ Primer Plus 第6版 中文版 清晰有书签PDF+源代码
读C++ Primer 之构造函数陷阱
读C++ Primer 之智能指针
读C++ Primer 之句柄类
C++11 获取系统时间库函数 time since epoch
C++11中正则表达式测试
本文永久更新链接地址:
评论暂时关闭