Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <numeric>
- #include <random>
- using namespace std;
- random_device rd;
- mt19937 g(rd());
- void remove(vector<int> &a) {
- for (int i = 0; i < a.size(); ++i) {
- if (a[i] & 1) {
- a.erase(a.begin() + i);
- --i;
- }
- }
- }
- void print(vector<int> &a) {
- for (auto el : a) {
- cout << el << " ";
- }
- }
- int no_in_vector(int x) {
- return x;
- }
- int main() {
- const int n = 50;
- vector<int> a(n);
- int x = rd() % (n + 1);
- iota(a.begin(), a.end(), 0);
- for (int i = x; i < n; ++i) ++a[i];
- shuffle(a.begin(), a.end(), g);
- cout << no_in_vector(x) << '\n';
- remove(a);
- print(a);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement