SHOW:
|
|
- or go back to the newest paste.
1 | #include <iostream> | |
2 | #include <random> | |
3 | #include <vector> | |
4 | using namespace std; | |
5 | template <typename Generator> | |
6 | double randomDoubleEngine(Generator& engine, double low_bound, double high_bound ) | |
7 | { | |
8 | if (low_bound > high_bound){ | |
9 | std::swap(low_bound, high_bound); | |
10 | } | |
11 | ||
12 | return std::uniform_real_distribution<>( low_bound, high_bound )( engine ); | |
13 | } | |
14 | ||
15 | void doSomething(){ | |
16 | ||
17 | std::mt19937 engine; | |
18 | ||
19 | double low = -1.7411500; | |
20 | double high = 2.2737999; | |
21 | for(int i =0; i < 20; i++){ | |
22 | std::cout << randomDoubleEngine(engine, low, high ) << std::endl; | |
23 | } | |
24 | } | |
25 | ||
26 | int main(){ | |
27 | ||
28 | ||
29 | for(int i = 0; i < 5; i++){ | |
30 | std::cout << "####################################\n"; | |
31 | std::cout << "# Call number: " << i << "\n"; | |
32 | doSomething(); | |
33 | std::cout << "####################################\n\n"; | |
34 | } | |
35 | ||
36 | ||
37 | ||
38 | return (EXIT_SUCCESS); | |
39 | } |