akela43

randomvector-increment_and_shuffle

Aug 7th, 2020
1,703
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.38 KB | None | 0 0
  1. #include <iostream>
  2. #include <numeric> // iota
  3. #include <random>
  4. #include <vector>
  5. using namespace std;
  6. int main()
  7. {
  8.     int len;
  9.     cin >> len;
  10.     vector<int> v(len);
  11.     iota(v.begin(), v.end(), 0); // заполняем 0, 1, 2...
  12.     shuffle(v.begin(), v.end(), std::mt19937{std::random_device{}()}); //перемешиваем
  13.     for (auto x: v) cout << x << " ";
  14. }
Advertisement
Add Comment
Please, Sign In to add comment