首页上一页 1 下一页尾页 3 条记录 1/1页
黑纸与白纸
发表在C语言图书答疑
2015-12-16
是否精华
是
否
版块置顶:
是
否
为什么药这样写,a && b + c + d + e == 3,a和b一定要这样求与吗,可以这样a + b + c + d + e == 3 吗
#include "stdafx.h"
void main()
{
int a, b, c, d, e;
for (a = 0; a <= 1; a++) /*对a、b、c、d、e穷举贴黑纸和白纸的所有可能*/
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 + c + d + e == 3 || !a && b + c + d + e !=
3) && (b && a + c + d + e == 0 || !b && a + c + d +
e != 0) && (c && a + b + d + e == 1 || !c && a + b
+ d + e != 1) && (d && a + b + c + e == 4 || !d &&
a + b + c + e != 4)) /*根据体列出相应条件*/
{
printf("0-黑纸,1-白纸\n");
printf("a is %d\nb is %d\nc is %d\nd is %d\ne is %d\n", a, b, c, d, e);
/*将最终结果输出*/
}
}
#include "stdafx.h"
void main()
{
int a, b, c, d, e;
for (a = 0; a <= 1; a++) /*对a、b、c、d、e穷举贴黑纸和白纸的所有可能*/
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 + c + d + e == 3 || !a && b + c + d + e !=
3) && (b && a + c + d + e == 0 || !b && a + c + d +
e != 0) && (c && a + b + d + e == 1 || !c && a + b
+ d + e != 1) && (d && a + b + c + e == 4 || !d &&
a + b + c + e != 4)) /*根据体列出相应条件*/
{
printf("0-黑纸,1-白纸\n");
printf("a is %d\nb is %d\nc is %d\nd is %d\ne is %d\n", a, b, c, d, e);
/*将最终结果输出*/
}
}