感觉这样的速度好慢呀!
程序代码:#include <stdio.h>
const int vol[] = {0x37, 0x3b, 0x5b, 0x5c, 0x6c, 0x6d, 0x76};
int person[5] = {0};
int get(int result, int day)
{
return (result & (1 << (6 - day))) != 0;
}
int judge2()
{
int i, j, ans, res = 0;
for (i = 0;i < 7;++i)
{
ans = 0;
for (j = 0;j < 5;++j)
{
ans += get( person[j], i );
}
res += ans == 5;
}
return res >= 3;
}
int judge3()
{
int i, j, ans;
for (i = 0;i < 7;++i)
{
ans = 0;
for (j = 0;j < 4;++j)
{
ans += get( person[j], i );
}
if (ans < 2) return 0;
}
return 1;
}
int judge4()
{
return 3 == get( person[1], 0 ) +
get( person[3], 0 ) + get( person[4], 0 );
}
int judge5()
{
return 2 == get( person[0], 3 ) + get( person[4], 3 );
}
int judge6()
{
int i, ans = 0;
for (i = 0;i < 7;++i)
{
ans += get( person[0], i ) && get( person[2], i );
}
return ans >= 4;
}
int judge()
{
return judge2() && judge3() && judge4() && judge5() && judge6();
}
void init(int tmp)
{
int i;
for (i = 0;i < 7;++i)
{
person[i] = vol[ tmp % 7 ];
tmp /= 7;
}
}
void Output()
{
int i, j;
for (i = 0;i < 5;++i)
{
for (j = 0;j < 7;++j)
{
printf("%d ", get( person[i], j) );
}
printf("\n");
}
printf("\n");
}
int main()
{
int i, all = 7 * 7 * 7 * 7 * 7;
for (i = 0;i < all;++i)
{
init(i);
if (judge()) Output();
}
return 0;
}
