70,037
社区成员
发帖
与我相关
我的任务
分享
#include<stdio.h>
static int b[3]={0,0,0};
static flag1[10]={1,1,1,1,1,1,1,1,1,1};
static flag2[1000][255];
static count;
int sort(int a[5],int depth );
void main()
{
int a[10]={1,2,3,4,5,6,7,8,9,10};
int p=0,q=0;
sort(a,0);
for(int i=0;i<count;i++)
{
{
for(int j=0;j<255;j++)
if(flag2[i][j]==1) {printf("%d ",j);}
}
printf("\n");
}
}
int sort(int a[10],int depth )
{
int i;
if(depth==3)
{
for(int f=0,int t=0;f<count;f++)
if(flag2[f][b[0]]==1&&flag2[f][b[1]]==1&&flag2[f][b[2]]==1)
{t++;}
if(t==0)
{flag2[count][b[0]]=1;flag2[count][b[1]]=1;flag2[count][b[2]]=1; count++;}
depth--;
return 1;
}
else
for(i=0;i<10;i++)
{
if(flag1[i]==1)
{
b[depth]=a[i];
flag1[i]=0;
depth++;
sort(a,depth);
depth--;
flag1[i]=1;
}
}
}