Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void permutations(std::string s, int pos = 0)
- {
- if (pos >= s.size())
- {
- std::cout << s << 'n';
- return;
- }
- else
- {
- for (int i = pos; i < s.size(); ++i)
- {
- std::swap(s[i], s[pos]);
- permutations(s, pos + 1);
- std::swap(s[i], s[pos]);
- }
- }
- }
Add Comment
Please, Sign In to add comment