|
|
|
|
#include "stdio.h"
|
|
|
|
|
int n=0;
|
|
|
|
|
int rest[7][7];//<2F><>Ϣ<EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD>ʱ<EFBFBD>䡢
|
|
|
|
|
void swap(int *a,int *b)//ʵ<>ֽ<EFBFBD><D6BD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
int m;
|
|
|
|
|
m=*a; *a=*b;
|
|
|
|
|
*b=m;
|
|
|
|
|
}
|
|
|
|
|
//0 6
|
|
|
|
|
void perm(int list[],int k,int m)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD>˵Ŀ<CBB5><C4BF><EFBFBD><EFBFBD><EFBFBD>Ϣʱ<CFA2>䴫<EFBFBD><E4B4AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
int i; int j;
|
|
|
|
|
if(k>m)//<2F><>K>Mʱִ<CAB1>С<EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
for(i=0;i<7;i++)
|
|
|
|
|
{
|
|
|
|
|
for(j=0;j<7;j++)
|
|
|
|
|
{
|
|
|
|
|
if(rest[i][j]==-1) return;
|
|
|
|
|
if(rest[i][j]!=list[i]) continue;
|
|
|
|
|
if(rest[i][j]==list[i]) break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
n++;
|
|
|
|
|
printf("Solution:%d\n",n);
|
|
|
|
|
printf("<EFBFBD><EFBFBD> Ǯ <20><> <20><> <20><> <20><> <20><>\n");
|
|
|
|
|
printf("================================================\n");
|
|
|
|
|
for(i=0;i<=m;i++)
|
|
|
|
|
{
|
|
|
|
|
switch(list[i])
|
|
|
|
|
{
|
|
|
|
|
case 1:printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ "); break;
|
|
|
|
|
case 2:printf("<EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD> "); break;
|
|
|
|
|
case 3:printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "); break;
|
|
|
|
|
case 4:printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "); break;
|
|
|
|
|
case 5:printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "); break;
|
|
|
|
|
case 6:printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "); break;
|
|
|
|
|
case 7:printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "); break;
|
|
|
|
|
default: break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
printf("\n\n");
|
|
|
|
|
}
|
|
|
|
|
else//<2F><>K<=m<><6D>ʱ<EFBFBD><CAB1>
|
|
|
|
|
{
|
|
|
|
|
for(i=k;i<=m;i++)
|
|
|
|
|
{
|
|
|
|
|
swap(&list[k],&list[i]);
|
|
|
|
|
perm(list,k+1,m);
|
|
|
|
|
swap(&list[k],&list[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
int main()
|
|
|
|
|
{
|
|
|
|
|
int list[]={1,2,3,4,5,6,7};//һ<>ܵ<EFBFBD>7<EFBFBD>졢
|
|
|
|
|
int i,j;
|
|
|
|
|
char ss[7][20]={"<EFBFBD><EFBFBD>","Ǯ","<EFBFBD><EFBFBD>","<EFBFBD><EFBFBD>","<EFBFBD><EFBFBD>","<EFBFBD><EFBFBD>","<EFBFBD><EFBFBD>"};
|
|
|
|
|
printf("============================ <20><> ӭ ʹ <20><> <20><> <20><> ϵ ͳ ============================");
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>䣺\n");
|
|
|
|
|
for(i=0;i<7;i++)
|
|
|
|
|
{
|
|
|
|
|
printf("%s: ",ss[i]);
|
|
|
|
|
for(j=0;j<7;j++)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܵ<EFBFBD><DCB5><EFBFBD>Ϣʱ<CFA2>䡢
|
|
|
|
|
{
|
|
|
|
|
scanf("%d",&rest[i][j]);
|
|
|
|
|
if(rest[i][j]==-1) break;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣʱ<CFA2><CAB1>λ-1ʱ<31><CAB1><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>һ<EFBFBD><D2BB><EFBFBD>˵Ŀ<CBB5><C4BF><EFBFBD><EFBFBD><EFBFBD>Ϣʱ<CFA2><CAB1>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
printf("\n\n\n");
|
|
|
|
|
perm(list,0,6);
|
|
|
|
|
getchar();
|
|
|
|
|
getchar();//getchar()<29><><EFBFBD><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļس<C4BB><D8B3>ַ<EFBFBD>'\n'
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|