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
|