Skip to content

Instantly share code, notes, and snippets.

@takashi1975
Created April 7, 2016 05:19
Show Gist options
  • Save takashi1975/5e68bf112bf9c7368b205e0ea5c2a3b6 to your computer and use it in GitHub Desktop.
Save takashi1975/5e68bf112bf9c7368b205e0ea5c2a3b6 to your computer and use it in GitHub Desktop.
C++11 ランダム 例
#include <random>
//処理例
{
//乱数の初期化
std::mt19937 rng;
{
// 非決定的な乱数生成器
std::random_device rnd;
// シード指定
rng.seed(rnd());
}
// 抽選範囲(1〜10)
std::uniform_int_distribution<int> rand10(1, 10);
// ランダム抽選
auto test = static_cast<int>(rand10(rng));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment