Guest User

Untitled

a guest
Dec 2nd, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. void permutations(std::string s, int pos = 0)
  2. {
  3. if (pos >= s.size())
  4. {
  5. std::cout << s << 'n';
  6. return;
  7. }
  8. else
  9. {
  10. for (int i = pos; i < s.size(); ++i)
  11. {
  12. std::swap(s[i], s[pos]);
  13. permutations(s, pos + 1);
  14. std::swap(s[i], s[pos]);
  15. }
  16. }
  17. }
Add Comment
Please, Sign In to add comment