Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <random>
- #include <time.h>
- using namespace std;
- template<typename Numeric, typename Generator = std::mt19937>
- Numeric random(Numeric from, Numeric to)
- {
- thread_local static Generator gen(std::random_device{}());
- using dist_type = typename std::conditional
- <
- std::is_integral<Numeric>::value
- , std::uniform_int_distribution<Numeric>
- , std::uniform_real_distribution<Numeric>
- >::type;
- thread_local static dist_type dist;
- return dist(gen, typename dist_type::param_type{ from, to });
- }
- int main()
- {
- srand(time(NULL));
- for (int i = 0; i < 500; i++) {
- 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;
- }
- getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement