#include<bits/stdc++.h>
using namespace std;
int check(string s, int start, int curr)
{
int i;
for(i=start;i<curr;i++)
{
if(s[i] == s[curr])
return 0;
}
return 1;
}
void parmutation(string s, int index, int n)
{
if(index>=n)
{
cout << s << endl;
return;
}
int i;
for(i=index;i<n;i++)
{
int c = check(s, index, i);
if(c == 1)
{
swap(s[index], s[i]);
parmutation(s, index+1, n);
swap(s[index], s[i]);
}
}
}
int main()
{
string s;
cin >> s;
sort(s.begin(), s.end());
cout << endl;
parmutation(s, 0, s.size());
return 0;
}
Comments
Post a Comment