??2. A、B、C、D、E五名学生有可能参加计算机竞赛,根据下列条件判断哪些
??人参加了竞赛:
?? (1)A参加时,B也参加;
?? (2)B和C只有一个人参加;
?? (3)C和D或者都参加,或者都不参加;
?? (4)D和E中至少有一个人参加;
?? (5)如果E参加,那么A和D也都参加。
#include <stdio.h>
struct bit
{
unsigned int a:1;
unsigned int b:1;
unsigned int c:1;
unsigned int d:1;
unsigned int e:1;
};
union match
{
unsigned char i;
struct bit matcher;
};
int main(int argc,char* argv[])
{
union match thematch;
thematch.i=0;
int i=0;
while(i++<32)
{
if(
((!thematch.matcher.a)||(thematch.matcher.a&&thematch.matcher.b)) &&//true
((thematch.matcher.b&&!thematch.matcher.c)||(!thematch.matcher.b&&thematch.matcher.c)) && //true
((thematch.matcher.c&&thematch.matcher.d)||(!thematch.matcher.c&&!thematch.matcher.d)) && //true
(thematch.matcher.d||thematch.matcher.e) && //true
((thematch.matcher.e&&thematch.matcher.a&&thematch.matcher.d)||!thematch.matcher.e)
)
{
printf("%d\t%d\t%d\t%d\t%d\t\n",thematch.matcher.a,thematch.matcher.b,thematch.matcher.c,thematch.matcher.d,thematch.matcher.e);
}
thematch.i++;
}
return 0;
}
/*
0 0 1 1 0
Terminated with return code 0
Press any key to continue ...
*/