如何评估x&& y || z? [英] how is x&&y||z evaluated?
本文介绍了如何评估x&& y || z?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
给定
int x = 1,y = 2,z;您能解释为什么结果:
pre> x&&& y || z
是1?
x&&& y = 1
x&& y || z = 1
解决方案
> x&& y || z
等效于
(x& y)|| z
如果 x = 1
和 y = 2
然后 x&& y
是 1& 2
这是 true&& true
这是 true
。
true || z
总是 true
。 z
甚至未评估
Given
int x=1,y=2,z;
Could you explain why the result for:
x && y || z
is 1?
x && y = 1
x && y || z = 1
解决方案
x && y || z
is equivalent to
(x && y) || z
if x=1
and y=2
then x&&y
is 1 && 2
which is true && true
which is true
.
true || z
is always true
. z
isn't even evaluated
这篇关于如何评估x&& y || z?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文