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++产生随机数 http://www.linuxidc.com/Linux/2010-06/26748.htm
C++ Primer Plus 第6版 中文版 清晰有书签PDF+源代码 http://www.linuxidc.com/Linux/2014-05/101227.htm
读C++ Primer 之构造函数陷阱 http://www.linuxidc.com/Linux/2011-08/40176.htm
读C++ Primer 之智能指针 http://www.linuxidc.com/Linux/2011-08/40177.htm
读C++ Primer 之句柄类 http://www.linuxidc.com/Linux/2011-08/40175.htm
C++11 获取系统时间库函数 time since epoch http://www.linuxidc.com/Linux/2014-03/97446.htm