Last active
June 2, 2020 06:00
-
-
Save bkb181/621f5a3a136d0f0475ac2f0b3beebfcf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void permutation(string str, int i) | |
{ | |
int n=str.size() | |
if (i == n - 1) | |
{ | |
cout << str << endl; | |
return; | |
} | |
for (int j = i; j < n; j++) | |
{ | |
swap(str[i], str[j]); | |
permutation(str, i + 1); | |
swap(str[i], str[j]); //swap is built-in function in CPP | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment