fork(12) download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <string>
  4. using namespace std;
  5.  
  6. int main() {
  7. std::string myStr = "abc";
  8. std::stable_sort(std::begin(myStr), std::end(myStr));
  9. do {
  10. for(auto&& element : myStr)
  11. std::cout << element << " ";
  12. std::cout << std::endl;
  13. } while (std::next_permutation(std::begin(myStr), std::end(myStr)));
  14. return 0;
  15. }
Success #stdin #stdout 0s 3280KB
stdin
Standard input is empty
stdout
a b c 
a c b 
b a c 
b c a 
c a b 
c b a