fork download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <string>
  4. #include <vector>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. string s;
  11.  
  12. cout << ">";
  13. cin >> s;
  14. vector<char> data(s.begin(), s.end());
  15. do {
  16. for (unsigned int i = 0; i < data.size(); i++) {
  17. cout << data[i];
  18. }
  19. cout << endl;
  20. } while (next_permutation(data.begin(), data.end()));
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0.01s 2816KB
stdin
abcd
stdout
>abcd
abdc
acbd
acdb
adbc
adcb
bacd
badc
bcad
bcda
bdac
bdca
cabd
cadb
cbad
cbda
cdab
cdba
dabc
dacb
dbac
dbca
dcab
dcba