fork(1) download
  1. #include <random>
  2. #include <iostream>
  3.  
  4. int main() {
  5. std::random_device rd;
  6. std::mt19937 generator(rd());
  7. std::uniform_real_distribution<double> distribution(0.0, 1.0);
  8.  
  9. auto first = [generator, distribution](double x) mutable -> double
  10. {
  11. return distribution(generator);
  12. };
  13.  
  14. auto second = [generator, distribution](double x) mutable -> double
  15. {
  16. return distribution(generator);
  17. };
  18.  
  19. std::cout << first(0.0) << ' ' << second(0.0) << std::endl;
  20. std::cout << first(0.1) << ' ' << second(0.1) << std::endl;
  21. std::cout << first(0.2) << ' ' << second(0.2) << std::endl;
  22. std::cout << first(0.3) << ' ' << second(0.3) << std::endl;
  23. std::cout << first(0.4) << ' ' << second(0.4) << std::endl;
  24. return 0;
  25. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
0.598428 0.598428
0.182467 0.182467
0.942196 0.942196
0.523324 0.523324
0.432487 0.432487