Mersenne Twister。 C++ 標準ライブラリでよく使われる代表的な疑似乱数生成器の一種。

<random> ヘッダから、std::mt19937(32bit版)と std::mt19937_64(64bit版)が提供される。

#include <iostream>
#include <random>
 
int main()
{
    std::mt19937 mt{};
 
    for (int count{ 1 }; count <= 10; ++count)
        std::cout << mt() << '\n';
}

指定した範囲の乱数が欲しい場合は、std::uniform_int_distribution などの分布と組み合わせて使う。

#include <iostream>
#include <random>
 
int main()
{
    std::mt19937 mt{};
    std::uniform_int_distribution die6{ 1, 6 };
 
    for (int count{ 1 }; count <= 10; ++count)
        std::cout << die6(mt) << '\n';
}

関連

参考