#include
#include
int count=0;
void backtrack1(int *X,int n,int k, int isused[])
{
int i;
for(i=0;i if(isused[i]==0)
{
X[k]=i+1;
isused[i]=1;
if(k==n-1)
{
printf("%d: ",++count);
for(k=0;k printf("%d ",X[k]);
printf("\n");
}
else
backtrack1(X,n,k+1,isused);
isused[i]=0;
}
}
int main()
{
int a[6]={1,2,3};
int b[6]={0};
backtrack1(a, 6, 0,b);
return 0;
}
阅读(922) | 评论(0) | 转发(0) |