LoginSignup
1
1

More than 1 year has passed since last update.

C++11のstd::mt19937をコンストラクタ以外でシード値を設定する方法

Last updated at Posted at 2017-10-10

#ソースコード

一応、メモ代わりに書いておきます。

main.cpp

#include <ctime>
#include <cstdint>
#include <cstdio>
#include <iostream>
#include <random>

int main(void){

    std::mt19937 Get_random;

    uint32_t seed=time(NULL);

    Get_random.seed(seed);

    std::cout << Get_random() << std::endl;

    return 0;
}

#結論

std::mt19937をコンストラクタ以外でシード値を設定する場合はメンバー関数seedを使います。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1