Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- int n;
- cin >> n;
- vector<int> a(n);
- srand(time(NULL));
- for (int i = 0; i < n; i++)
- a[i] = rand() % 1000;
- for (int i = 1; i < n; i+=2)
- swap(a[i], a[i-1]);
- for (int i : a)
- cout << i << " ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement