#include<stdio.h>
#include<string.h>
typedef char Mytype;
void swap(Mytype a[],int i,int j)
{
char temp;
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
void print(Mytype a[])
{
printf("%s/n",a);
}
bool judge_same(Mytype a[] ,int end, int beg)
{
int i;
for(i = beg;i<end;i++)
if(a[i] == a[end])return true;
return false;
}
void recu_p(Mytype a[] , int l , int r)//算法:分成兩段考慮,前一段固定,
//後一段每一個數同前一段的最後一個數
//進行交換再遞歸
{
int i;
if(l==r)
{
print(a);
return ;
}
recu_p(a,l+1,r);
for(i = l + 1;i <= r;i ++)
{
if(!judge_same(a,i,l))//判斷是否有重複!有重複的時候,排列種類就要減少
{//如果要實現按字母序排列,必須在交換了一個數後,把這個數放在最前,其他數後移,
//這樣需額外的移動數據時間
swap(a,i,l);
recu_p(a,l+1,r);
swap(a,i,l);
}
}
}
int main()
{
Mytype a[20];
int len ;
scanf("%s",a);
len = strlen(a);
recu_p(a,0,len -1);
print(a);
return 0;
}