Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <random>
  4. #include <time.h>
  5.  
  6. using namespace std;
  7.  
  8. template<typename Numeric, typename Generator = std::mt19937>
  9. Numeric random(Numeric from, Numeric to)
  10. {
  11. thread_local static Generator gen(std::random_device{}());
  12.  
  13. using dist_type = typename std::conditional
  14. <
  15. std::is_integral<Numeric>::value
  16. , std::uniform_int_distribution<Numeric>
  17. , std::uniform_real_distribution<Numeric>
  18. >::type;
  19.  
  20. thread_local static dist_type dist;
  21.  
  22. return dist(gen, typename dist_type::param_type{ from, to });
  23. }
  24.  
  25. int main()
  26. {
  27. srand(time(NULL));
  28.  
  29. for (int i = 0; i < 500; i++) {
  30. cout << "INSERT INTO Place(id_os,data,za_miesiac,podstawa,premia)\n VALUES(" << rand() % 40 + 1 << ", To_Date('"<< rand() % 39 + 1980 << "/" << rand() % 12 + 1 << "/" << rand() % 28 + 1 << "', 'YYYY/MM/DD'), '" << rand() % 12 + 1 << "', " << rand() % 3400 + 2100 << "," << random <double>(100.00,1500.00)<< ");" << endl;
  31. }
  32.  
  33. getchar();
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement