#include<random> #include<iostream> int main() { //定义均匀分布对象,均匀分布区间(a,b)为(2,6) std::uniform_real_distribution<double> uid{ 2,6 }; ////均匀分布区间(a,b) //std::cout << uid.a() << " " << uid.b() << std::endl; //定义随机数种子 std::random_device rd; //定义默认随机数生成器 std::default_random_engine dre{ rd() }; std::cout << "十个随机数如下" << std::endl; for (int i = 0; i < 10; ++i) { std::cout << uid(dre) << std::endl; } return 0; }
标签:std,实数,均匀分布,C++,随机,include From: https://www.cnblogs.com/limitless-coding/p/16939520.html