Advertisement
cd62131

Permutations

Mar 21st, 2014
1,491
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.29 KB | None | 0 0
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <vector>
  4. using namespace std;
  5. int main() {
  6.   vector<int> v;
  7.   const int n = 4;
  8.   for (int i = 0; i < n; i++) v.push_back(i + 1);
  9.   do {
  10.     for (int e: v) cout << e << ' '; cout << endl;
  11.   } while (next_permutation(v.begin(), v.end()));
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement