我正在尝试使用C++ STD TechnicalReport1扩展生成遵循正态分布的数字,但是这段代码(改编自此文章):
mt19937 eng;
eng.seed(SEED);
normal_distribution<double> dist;
// XXX if I use the one below it exits the for loop
// uniform_int<int> dist(1, 52);
for (unsigned int i = 0; i < 1000; ++i) {
cout << "Generating " << i << "-th value" << endl;
cout << dist(eng) << endl;
}
仅打印一条“正在生成…”日志消息,然后永远不会退出for循环! 如果我使用我注释掉的distribution,则它会终止,所以我想知道我做错了什么。 有任何想法吗?
非常感谢!