Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- void permute(string a, int l, int r)
- {
- if (l == r)
- cout<<a<<endl;
- else
- {
- for (int i = l; i <= r; i++)
- {
- swap(a[l], a[i]);
- permute(a, l+1, r);
- swap(a[l], a[i]);
- }
- }
- }
- int main()
- {
- string str = "ABC";
- int n = str.size();
- permute(str, 0, n-1);
- return 0;
- }
Add Comment
Please, Sign In to add comment