以下是我的代码:
uniform_int_distribution<>temp(-1,1);
default_random_engine e((unsigned int)time(0));
for(int a=0;a<50;a++){
cout<<temp(e)<<endl;
}
你知道,我希望数字范围是-1、0、1,这三个数字。 实际上,结果通常只包含0和1。 如果我运行这个程序几次,很少情况下-1会成为最后一个数字。 我不知道为什么,uniform_int_distribution应该包含-1,对吧?
default_random_engine
使用一个实现定义的引擎。 - Jesse Good