SHOW:
|
|
- or go back to the newest paste.
| 1 | #include <iostream> | |
| 2 | #include <iterator> | |
| 3 | #include <random> | |
| 4 | using namespace std; | |
| 5 | int main() {
| |
| 6 | const auto n = 10U; | |
| 7 | int box[n]; | |
| 8 | cout << "a, b >>> "; | |
| 9 | int a, b; | |
| 10 | cin >> a >> b; | |
| 11 | if (a > b) swap(a, b); | |
| 12 | const uniform_int_distribution<> uid(a, b); | |
| 13 | mt19937 gen{ random_device()() };
| |
| 14 | auto rand = [&] { return uid(gen); };
| |
| 15 | generate(begin(box), end(box), rand); | |
| 16 | auto iter = ostream_iterator<int>(cout, " "); | |
| 17 | copy(begin(box), end(box), iter); | |
| 18 | cout.put('\n');
| |
| 19 | system("pause");
| |
| 20 | } |