fork download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <iterator>
  4. #include <random>
  5. #include <vector>
  6.  
  7. template < typename Generator = std::mt19937, typename Distribution = std::uniform_real_distribution<double>, typename T = double >
  8. struct randGen
  9. {
  10. randGen(const Generator & eng, T low, T high) : m_engine(eng), m_distribution(low, high) {}
  11. T operator()() { return m_distribution(m_engine); }
  12.  
  13. private:
  14.  
  15. Generator m_engine;
  16. Distribution m_distribution;
  17. };
  18.  
  19. int main(){
  20. std::random_device rd;
  21. std::mt19937 engine1(rd());
  22. randGen<std::mt19937, std::uniform_real_distribution<double>, double > myinstance( engine1, 18.3, 180.34 );
  23.  
  24.  
  25. std::vector<double> threshold11, threshold21;
  26. for(int i=0; i < 30; i++){
  27. threshold11.push_back(myinstance());
  28. }
  29. for(int i=0; i < 30; i++){
  30. threshold21.push_back(myinstance());
  31. }
  32.  
  33. std::sort(threshold11.begin(), threshold11.end());
  34. std::sort(threshold21.begin(), threshold21.end());
  35.  
  36. std::vector<double>::const_iterator it;
  37.  
  38. for(it=threshold11.begin(); it != threshold11.end(); it++){
  39. std::cout << *it << "\n";
  40. }
  41. std::cout << "\n\n\n";
  42. for(it=threshold21.begin(); it != threshold21.end(); it++){
  43. std::cout << *it << "\n";
  44. }
  45. }
Runtime error #stdin #stdout 0s 2960KB
stdin
Standard input is empty
stdout
Standard output is empty