人参加了竞赛:
(1)A参加时,B也参加;
(2)B和C只有一个人参加;
(3)C和D或者都参加,或者都不参加;
(4)D和E中至少有一个人参加;
(5)如果E参加,那么A和D也都参加。
[此贴子已经被作者于2006-7-29 6:03:12编辑过]
#include<stdio.h>
int main(void)
{
int A, B, C, D, E;
for (A = 0; A <= 1; ++A)
for (B = 0; B <= 1; ++B)
for (C = 0; C <= 1; ++C)
for (D = 0; D <= 1; ++D)
for (E = 0; E <= 1; ++E)
{
if ((A + B == 2 || A == 0) && (B + C == 1)
&& (C + D == 2 || C + D == 0) && (D + E == 1 || D + E == 2)
&& (E + A + D == 3 || E == 0) )
{
printf("A will %s attend!\n", A?"":"not");
printf("B will %s attend!\n", B?"":"not");
printf("C will %s attend!\n", C?"":"not");
printf("D will %s attend!\n", D?"":"not");
printf("E will %s attend!\n", E?"":"not");
}
}
system("Pause");
return 0;
}
#include<stdio.h>
int main(void)
{
int A, B, C, D, E;
for (A = 0; A <= 1; ++A)
for (B = 0; B <= 1; ++B)
for (C = 0; C <= 1; ++C)
for (D = 0; D <= 1; ++D)
for (E = 0; E <= 1; ++E)
{
if ((A + B == 2 || A == 0) && (B + C == 1)
&& (C + D == 2 || C + D == 0) && (D + E == 1 || D + E == 2)
&& (E + A + D == 3 || E == 0) )
{
printf("A will %s attend!\n", A?"":"not");
printf("B will %s attend!\n", B?"":"not");
printf("C will %s attend!\n", C?"":"not");
printf("D will %s attend!\n", D?"":"not");
printf("E will %s attend!\n", E?"":"not");
}
}
system("Pause");
return 0;
}
利用离散数学将上面五个命题进行化简可以吗?
兄弟,有没有考虑使用数组来解决这个问题.
[此贴子已经被作者于2006-7-29 6:01:34编辑过]