#define _CRT_SECURE_NO_WARNINGS

#include<stdio.h> 

void swap(char *a,char *b) 
{ 
	char t; 
	t = *a; 
	*a = *b; 
	*b = t; 
} 
void print(char *a,int length,int* t) 
{ 
	for(int i=0;i<length;++i) printf("%c",a[i]); 
	printf("\n");
	(*t)++;
} 
void permut(char * a,int p,int q,int length,int* t) 
{ 
	int i = 0; 
	for(i = p;i<=q;i++) 
	{ 
		swap(&a[i],&a[p]); 
		if(p == q) 	print(a,length,t); 
		permut(a,p+1,q,length,t); 
		swap(&a[i],&a[p]); 
	} 

} 
int main() 
{ 
	int count=0;
	char a[] = {'a','b','c','d','e'}; 
	int slen=sizeof(a)/sizeof(char);
	permut(a,0,slen-1,slen,&count);
	printf("共有全排列%d组\n",count);
	return 0; 
}