答案是:等价
证明如下:
1. a = 0, b = 0时, a || b == 0, !(a || b) == 1, !a && !b == 1
2. a = 0, b = 1时, a || b == 1, !(a || b) == 0, !a && !b == 0
3. a = 1, b = 0时, 和2相同
4. a = 1, b = 1时, a || b == 1, !(a || b) == 0, !a && !b == 0
用代码证明如下:
#include <stdio.h>
int main()
{
int a, b;
a = 0, b = 0;
if ((!(a || b)) == (!a && !b)) printf("Equal.\n");
a = 1, b = 0;
if ((!(a || b)) == (!a && !b)) printf("Equal.\n");
a = 0, b = 1;
if ((!(a || b)) == (!a && !b)) printf("Equal.\n");
a = 1, b = 1;
if ((!(a || b)) == (!a && !b)) printf("Equal.\n");
return 0;
}
输出结果如下:
Equal.
Equal.
Equal.
Equal.
温馨提示:内容为网友见解,仅供参考