我之前使用rand,后来才听说知道这玩意儿是伪随机数,之后就被我抛弃了。
现在我用的是uniform_int_distribution<>,我写个代码大家就懂了。
#include <bits/stdc++.h>
using namespace std;
int main()
{
random_device rd;
mt19937 root(rd());
uniform_int_distribution<> randn(1, 500);
for(int i = 1; i <= 5e5; i++)
cout << randn(root) << endl;
return 0;
}
然后又发现这玩意儿好像每次都一样。。。
求更加均匀的随机数。C++语言。难写没关系。