public static member function (公共靜態成員函式)
<random>
static constexpr result_type max();
最大值
返回值
modulus-1 (模數-1)
result_type (結果型別)是一個成員型別,定義為第一個類模板引數的別名 (UIntType).
示例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
// linear_congruential_engine::min and max
#include <iostream>
#include <chrono>
#include <random>
int main ()
{
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::minstd_rand0 generator (seed); // minstd_rand0 is a standard linear_congruential_engine
std::cout << generator() << " is a random number between ";
std::cout << generator.min() << " and " << generator.max();
return 0;
}
|
可能的輸出
204181028 is a random number between 1 and 2147483646
|