Skip to content

Latest commit

 

History

History
77 lines (57 loc) · 1.22 KB

File metadata and controls

77 lines (57 loc) · 1.22 KB

operator()

  • random[meta header]
  • std[meta namespace]
  • independent_bits_engine[meta class]
  • function[meta id-type]
  • cpp11[meta cpp]
result_type operator()();

概要

乱数生成を行う。

効果

ランダムな値を生成し、内部状態を進める。

戻り値

ランダムな値を生成して返す。
値の範囲は[min(), max()]である。つまり、最小値と最大値両方を含む。

計算量

償却定数時間

#include <iostream>
#include <random>
#include <cstdint>

int main()
{
  std::independent_bits_engine<std::mt19937, 64, std::uint64_t> engine;

  for (int i = 0; i < 10; ++i) {
    // 乱数生成
    std::uint64_t result = engine();

    std::cout << result << std::endl;
  }
}
  • engine()[color ff0000]
  • std::uint64_t[link /reference/cstdint/uint64_t.md]

出力例

152607844
823378840
578354438
2035308228
1004016855
280090412
101929267
1784484492
944975825
1190959745

バージョン

言語

  • C++11

処理系

参照