C++中uniform_real_distribution类的max()方法用于获取可通过此unique_real_distribution生成的最大可能值。
句法:
result_type max() const;
参数:此方法不接受任何参数。
返回值:该方法返回此uniform_real_distribution中可能生成的最大值。
例子:
// C++ code to demonstrate
// the working of max() function
#include
// for uniform_real_distribution function
#include
using namespace std;
int main()
{
double a = 10, b = 20.5;
// Initializing of uniform_real_distribution class
uniform_real_distribution distribution(a, b);
// Using max()
cout << "Max value that can be generated"
<< " by this uniform_real_distribution: "
<< distribution.max() << endl;
return 0;
}
输出:
Max value that can be generated by this uniform_real_distribution: 20.5
参考: http://www.cplusplus.com/reference/random/uniform_real_distribution/max/
要从最佳影片策划和实践问题去学习,检查了C++基础课程为基础,以先进的C++和C++ STL课程基础加上STL。要完成从学习语言到DS Algo等的更多准备工作,请参阅“完整面试准备课程” 。