C++中uniform_real_distribution類的reset()方法用於重置此uniform_real_distribution。
用法:
void reset();
參數:此方法不接受任何參數。
返回值:此方法不返回任何內容。
例:
// C++ code to demonstrate
// the working of reset() function
#include <iostream>
// for uniform_real_distribution function
#include <random>
using namespace std;
int main()
{
double a = 10, b = 20.5;
default_random_engine generator;
// Initializing of uniform_real_distribution class
uniform_real_distribution<double> distribution(a, b);
cout << "Next value in uniform_int_distribution:"
<< distribution(generator) << endl;
cout << "Next value in uniform_int_distribution:"
<< distribution(generator) << endl;
cout << "Next value in uniform_int_distribution:"
<< distribution(generator) << endl;
// Using reset()
distribution.reset();
cout << endl
<< "uniform_int_distribution has been reset."
<< endl
<< endl;
// Now the next value won't be in the previous progression
// and will be another progression
cout << "Now next value in uniform_int_distribution:"
<< distribution(generator) << endl;
return 0;
}
輸出:
Next value in uniform_int_distribution:11.3811 Next value in uniform_int_distribution:14.8158 Next value in uniform_int_distribution:12.2991 uniform_int_distribution has been reset. Now next value in uniform_int_distribution:17.1281
參考: http://www.cplusplus.com/reference/random/uniform_real_distribution/reset/
相關用法
- C++ std::uniform_int_distribution reset()用法及代碼示例
- C++ bitset reset()用法及代碼示例
- C++ std::uniform_int_distribution max()用法及代碼示例
- C++ std::uniform_int_distribution a()用法及代碼示例
- C++ std::uniform_int_distribution min()用法及代碼示例
- C++ std::uniform_int_distribution b()用法及代碼示例
- C++ std::uniform_real_distribution b()用法及代碼示例
- C++ std::uniform_real_distribution min()用法及代碼示例
- C++ std::uniform_real_distribution max()用法及代碼示例
- C++ std::uniform_real_distribution a()用法及代碼示例
- C++ cin get()用法及代碼示例
注:本文由純淨天空篩選整理自srinam大神的英文原創作品 std::uniform_real_distribution reset() method in C++ with Examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。