fork download
  1. #include <iostream>
  2. #include <random>
  3. using namespace std;
  4. double GenerateRandom(double min, double max)
  5. {
  6. std::random_device rseed;
  7. std::mt19937 rgen(rseed()); // mersenne_twister
  8. std::uniform_real_distribution<double> distrbution(min, max); //[min,max]
  9. double randNumber = distrbution(rgen);
  10. return randNumber;
  11. }
  12. int main() {
  13. // your code goes here
  14. for(int i=0; i<10; i++)
  15. {
  16. cout<<GenerateRandom(0,1.0)<<endl;
  17. }
  18. return 0;
  19. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
0.674594
0.556458
0.619446
0.438052
0.0567557
0.638247
0.481065
0.00613295
0.793323
0.954589