|
|
@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
int n = 0;
|
|
|
|
|
|
|
|
int rest[7][7];
|
|
|
|
|
|
|
|
void swap(int *a, int *b)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int m;
|
|
|
|
|
|
|
|
m = *a;
|
|
|
|
|
|
|
|
*a = *b;
|
|
|
|
|
|
|
|
*b = m;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void perm(int list[], int k, int m)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
int j;
|
|
|
|
|
|
|
|
if(k > m)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
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("赵 钱 孙 李 周 吴 陈\n");
|
|
|
|
|
|
|
|
for(i = 0; i <= m; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
switch (list[i])
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
case 1: printf("星期一 ");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: printf("星期二 ");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3: printf("星期三 ");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4: printf("星期四 ");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 5: printf("星期五 ");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 6: printf("星期六 ");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 7: printf("星期日 ");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("\n\n\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
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};
|
|
|
|
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
char ss[7][20]={"赵","钱","孙","李","周","吴","陈"};
|
|
|
|
|
|
|
|
printf("===========================欢迎使用排班系统===================================\n");
|
|
|
|
|
|
|
|
printf("请输入下列人选选择休息的可能时间,每输完一个人的休息时间,输入-1后按回车\n");
|
|
|
|
|
|
|
|
for(i = 0; i < 7; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("%s:",ss[i]);
|
|
|
|
|
|
|
|
for(j = 0; j < 7; j++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
scanf("%d", &rest[i][j]);
|
|
|
|
|
|
|
|
if(rest[i][j] == -1)
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("\n\n\n");
|
|
|
|
|
|
|
|
perm(list, 0, 6);
|
|
|
|
|
|
|
|
printf("可能的方案有:%d种", n);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getchar();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|