c++11 生产随机数

#include <random>
#include <iostream>
 
int main()
{
    std::random_device rd;
    std::mt19937 gen(rd());
    std::uniform_int_distribution<> dis(1, 6);
 
    for (int n=0; n<10; ++n)
        std::cout << dis(gen) << ' ';
    std::cout << '\n';
}

 http://en.cppreference.com/w/cpp/numeric/random/uniform_int_distribution

你可能感兴趣的:(C++)