#include "stdafx.h"
using namespace std;
char p[10];
void perm(char s[], int i, int n){
int j;
char temp;
for(j=0;j<n;++j){
if(j!=0 && s[j]==s[j-1]);
else if(s[j]!='#'){
p[i]=s[j];
s[j]='#';
if(i==n-1){
p[n]='/0';
printf("%s/r/n", p);
}else{
perm(s,i+1,n);
}
s[j]=p[i];
}
}
}
void main() {
char s[]="accb";
perm(s,0,strlen(s));
}