//
#include "stdafx.h"
#include "string.h"
#include<stdio.h>
char *WEEK[7] = {"星期天", "星期壹", "星期二", "星期三","星期四","星期五","星期六"};
struct demand
{
char name[5];
int day[7];
} man[7];
main()
{
int IsChecked(int p[]);
int t=0, j, ren[7];
long i,k;
printf("****************保安值班系統****************\n");
printf("請各位分別輸入各自合適的休假日,如趙保安選擇星期二和星期三,就輸入2 3 8 8 8 8 8.\n");
printf(" 數字0 1 2 3 4 5 6分別代表星期天 星期壹 星期二 星期三 星期四 星期五 星期六,註意要輸入星期天請輸入數字0 \n");
for(i=0;i<7;i++)
{
printf("請第%d個人輸入\n",i+1);
for(k=0;k<7;k++)
{
scanf("%d",&man[i].day[k]);
}
printf("妳輸入的day是:");
for(k=0;k<7;k++)
{
printf("%d ",man[i].day[k]);
}
printf("\n");
}
printf("**********************************************");
printf("\n* 趙, 錢, 孫, 李, 周 , 吳, 陳 , *\n");
printf("*--------------------------------------------*\n");
printf("");
for (i=0; i<2097152; ++i)
{
for (j=0; j<7; ++j)
{
ren[j]= (i>>(3*j))&7; //*通過這個循環,窮盡0-7在數組中所有的排列組合方式*//
}
if (!(ren[0]==man[0].day[0] || ren[0]==man[0].day[1]||ren[0]==man[0].day[2]||ren[0]==man[0].day[3]||ren[0]==man[0].day[4]||ren[0]==man[0].day[5]||ren[0]==man[0].day[6]))continue;//*如果趙保安不是休周二或周四,就不用循環了。*//
else if (!(ren[1]==man[1].day[0] || ren[1]==man[1].day[1]||ren[1]==man[1].day[2]||ren[1]==man[1].day[3]||ren[1]==man[1].day[4]||ren[1]==man[1].day[5]||ren[1]==man[1].day[6]))continue; //*如果錢保安不是休周壹或周六,就不用循環了。*//
else if (!(ren[2]==man[2].day[0] || ren[2]==man[2].day[1]||ren[2]==man[2].day[2]||ren[2]==man[2].day[3]||ren[2]==man[2].day[4]||ren[2]==man[2].day[5]||ren[2]==man[2].day[6]))continue; //*如果孫保安不是休周三或周日,就不用循環了。*//
else if (!(ren[3]==man[3].day[0] || ren[3]==man[3].day[1]||ren[3]==man[3].day[2]||ren[3]==man[3].day[3]||ren[3]==man[3].day[4]||ren[3]==man[3].day[5]||ren[3]==man[3].day[6]))continue; //*如果李保安不是休周五,就不用循環了。*//
else if (!(ren[4]==man[4].day[0] || ren[4]==man[4].day[1]||ren[4]==man[4].day[2]||ren[4]==man[4].day[3]||ren[4]==man[4].day[4]||ren[4]==man[4].day[5]||ren[4]==man[4].day[6]))continue; //*如果周保安不是休周壹或周四或周六,就不用循環了。*//
else if (!(ren[5]==man[5].