ぶんしょ問題
1030 ワード
/* 0,1,2,3,4 5 , 5 A,B,C,D,E, , :
like[i][j]=1 i j ||0 i j , , ,
*/
#include
int sum=0;//
int like[5][5]={{0,0,1,1,0},{1,1,0,0,1},{0,1,1,0,1},{0,0,0,1,0},{0,1,0,0,1}};// A E
int book[5]={0,0,0,0,0};// ,
int take[5];//take[n]=j n j
void fun(int n)//n n
{
int i,j,k;
for(i=0;i<=4;i++)
{
if(like[n][i]>0&&book[i]==0)// n i , i
{
take[n]=i;
book[i]=1;
if(n==4)//
{
sum++;
printf(" %d :
",sum);
for(k=0;k<=4;k++)
{
printf("%d->%c
",take[k],k+65);
}
printf("
");
}
else
{fun(n+1);// ,
}
book[i]=0; // i , i , ,
}
}
}
int main()
{
int n=0;
fun(0);
return 0;
}
// ,