int ElemCount = 0;
// 交换元素
void swap(char *a, char *b)
{
char tmp;
tmp = *a;
*a = *b;
*b = tmp;
}
// 递归全排列
void perm(char c[], int s, int e)
{
if(s == e)
{ // 开始index == 结束index
if(c[0]=='T')
{
for(int i=0; i<=e; i++)
printf("%c",c[i]);
printf("\n");
ElemCount ++;
}
}
else
{
for(int i = s; i <= e; i++)
{
int mark = 0;
for(int j = s; j < i; j ++)
{
if(c[j] == c[i])
{
mark = 1;
break;
}
}
if(1 == mark) continue;
swap(&c[s], &c[i]);
perm(c, s + 1, e);
swap(&c[s], &c[i]);
}
}
}