1.2.3.4实现全排列
#include <stdio.h>
#include <string.h>
int a[4]={1,2,3,4};
void perm(int left, int right)
{
if (left==right){
for(int i=0;i<right+1;i++)
printf("%d",a[i]);
printf("\n");
}
else{
for(int i=left;i<=right;i++){
int temp=a[left];
a[left]=a[i];
a[i]=temp;
perm(left+1,right);
temp=a[left];
a[left]=a[i];
a[i]=temp;
}
}
}
int main()
{
perm(0,3);
return 0;
}