當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


C++ std::uniform_real_distribution min()用法及代碼示例


C++中uniform_real_distribution類的min()方法用於獲取此uniform_real_distribution可以生成的最小可能值。

用法:

result_type min() const;

參數:此方法不接受任何參數。


返回值:此方法在此uniform_real_distribution中返回可能的最小生成值。

例:

// C++ code to demonstrate 
// the working of min() function 
  
#include <iostream> 
  
// for uniform_real_distribution function 
#include <random> 
  
using namespace std; 
  
int main() 
{ 
    double a = 10, b = 20.5; 
  
    // Initializing of uniform_real_distribution class 
    uniform_real_distribution<double> distribution(a, b); 
  
    // Using min() 
    cout << "Min value that can be generated"
         << " by this uniform_real_distribution:"
         << distribution.min() << endl; 
  
    return 0; 
}
輸出:
Min value that can be generated by this uniform_real_distribution:10

參考: http://www.cplusplus.com/reference/random/uniform_real_distribution/min/



相關用法


注:本文由純淨天空篩選整理自srinam大神的英文原創作品 std::uniform_real_distribution min() method in C++ with Examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。