// construct a trivial random generator engine from a time-based seed:
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::default_random_engine generator (seed);
std::normal_distribution<int> distribution (132,20);
std::cout << "some Normal-distributed results:" << std::endl;
for (int i=0; i<10; ++i)
std::cout << distribution(generator) << std::endl;
从cplusplus的这个代码示例中,我得到运行时错误“整数除以零”。我唯一改变的是 normal_distribution from double
to的类型int
及其均值和标准差。
有什么建议吗?