c++11生産乱数

482 ワード

#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 << '
'; }

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