fork download
  1. #include <algorithm>
  2. #include <iostream>
  3.  
  4. void print_combination(std::vector<int*> v)
  5. {
  6. std::sort(v.begin(), v.end());
  7. do {
  8. for (auto* p : v) {
  9. std::cout << ' ' << *p;
  10. }
  11. std::cout << std::endl;
  12.  
  13. } while (std::next_permutation(v.begin(), v.end()));
  14. }
  15.  
  16. int main() {
  17. int integers[] = {1, 3, 1};
  18.  
  19. print_combination({&integers[0], &integers[1], &integers[2]});
  20. }
  21.  
Success #stdin #stdout 0s 3276KB
stdin
Standard input is empty
stdout
 1 3 1
 1 1 3
 3 1 1
 3 1 1
 1 1 3
 1 3 1