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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。