#include"stdlib.h"
#include"stdio.h"
#define size 5
struct plist{
int status;
int num;
struct plist *ar[size*2-1];
};
int count = 0;
void execute(struct plist **p,int *temp,int layer)
{
int i = 0,ii = 0;
if(layer < size)
{
for(i = 0; i < size-1;i++)
{
if(p[i]->status == 0)
{
p[i]->status = 1;
temp[layer] = p[i]->num;
execute(p[i]->ar,temp,layer+1);
p[i]->status = 0;
}
}
}else
{
count++;
printf("/n");
for(i = 0 ; i < size; i++)
{
printf("%d/t",temp[i]);
}
printf("/n第%d柱",count);
}
}
void main()
{
int soure_a[size] = {0,1,2,3,4};
struct plist *p[size];
int temp[size];
int i,ii , j;
for(i = 0; i < size*2; i++)
{
p[i] = (struct plist *)malloc(sizeof(struct plist));
p[i]->status = 0;
p[i]->num = soure_a[i];
}
/**
*把熟组的类容写入指针
**/
for(i = 0; i < size; i++)
{
for(j = 0 , ii = 0; j < size ;j++)
{
if( i != j)
{
p[i]->ar[ii]=p[j];
ii++;
}
}
}
for(i = 0; i < size; i++)
{
p[i]->status = 1;
temp[0] = p[i]->num;
execute(p[i]->ar,temp,1);
p[i]->status = 0;
}
}