#include <stdio.h>
void permutation(char a[], int m, int n)
{
int i;
char t;
if (m<n-1)
{
permutation(a, m+1, n);
for (i=m+1;i<n;i++)
{
t=a[m];
a[m]=a[i];
a[i]=t;
permutation(a, m+1, n);
t=a[m];
a[m]=a[i];
a[i]=t;
}
}
else
{
printf("%s/n", a);
}
}
int main( int argc, char* argv[] )
{
char a[] = "12345";
permutation(a, 0, 5);
getchar();
return 0;
}