c++ 随机数
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
#include <string> #include <random> #include <functional> // bind() using namespace std; int main() { random_device rd; mt19937 gen = mt19937(rd()); uniform_real_distribution<> dis(40, 100); auto randFun = bind(dis, gen); for(int i=0; i<5; i++) { cout << (int)randFun() << "\t" << (int)randFun() << "\t" << (int)randFun() << endl; } } |