fork download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <vector>
  4. using namespace std;
  5.  
  6. int main() {
  7. std::vector<int> v{1,2,3};
  8. do
  9. {
  10. std::cout << v[0] << " " << v[1] << " " << v[2] << "\n";
  11. }
  12. while (std::next_permutation(v.begin(), v.end()));
  13. std::cout << v[0] << " " << v[1] << " " << v[2] << "\n";
  14.  
  15. return 0;
  16. }
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
1 2 3
1 3 2
2 1 3
2 3 1
3 1 2
3 2 1
1 2 3