Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iterator>
- #include <random>
- using namespace std;
- int main() {
- const auto n = 10U;
- int box[n];
- cout << "a, b >>> ";
- int a, b;
- cin >> a >> b;
- if (a > b) swap(a, b);
- const uniform_int_distribution<> uid(a, b);
- mt19937 gen{ random_device()() };
- auto rand = [&] { return uid(gen); };
- generate(begin(box), end(box), rand);
- auto iter = ostream_iterator<int>(cout, " ");
- copy(begin(box), end(box), iter);
- cout.put('\n');
- system("pause");
- }
Add Comment
Please, Sign In to add comment