c++(生成随机数)
#include <ctime>
#include <random>
void test01()
{
//uniform_int_distribution<unsigned> u(0,9);随机生成无符号int型0到9
uniform_real_distribution<double> u(0, 1);//随机浮点数
//uniform_real_distribution<> u(0, 1); 默认生成double值,取值在0到1之间
default_random_engine e(time(0));//time头文件是ctime e:随机数引擎对象
for (size_t i = 0; i < 10; i++)
{
cout << u(e) << " "<<endl;
}
}