Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- int n;
- cin >> n;
- vector<int> v(n);
- for (int i = 0; i < n; ++i) v[i] = i;
- int m = n;
- while (m > 0) {
- vector<int> curr(m);
- copy(v.begin(), v.begin()+m, curr.begin());
- do {
- for (int x : curr) printf("%i ", x);
- cout << '\n';
- } while (next_permutation(curr.begin(), curr.end()));
- m--;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement