Advertisement
Guest User

Untitled

a guest
Feb 18th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include <algorithm>
  2. #include <iterator>
  3. #include <vector>
  4. #include <iostream>
  5.  
  6. using namespace std;
  7.  
  8. void printPermutations (int items [], int itemsLength)
  9. {
  10. vector<int> v;
  11. for (int i=0; i!=itemsLength; ++i) v.push_back(items[i]);
  12.  
  13. while (next_permutation(v.begin(), v.end() ) )
  14. {
  15. copy(v.begin(), v.end(), ostream_iterator<int>(cout, ""));
  16. cout << endl;
  17. }
  18. }
  19.  
  20.  
  21. int main()
  22. {
  23.  
  24. const int sizeArray = 3;
  25. int Array [sizeArray] = {1,2,3};
  26.  
  27. printPermutations(Array,sizeArray);
  28.  
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement