如果和其他两个区块同时执行 [英] Simultaneous execution of both if and else blocks
问题描述
在C或C ++
如果(X)
语句1;
其他
语句2;
有关什么的值x
都将语句被执行?
我知道我们可以执行的if-else
起来是这样的:
如果(1){
转到ELSE;
}
其他{
其他:
}
有什么办法,就像一个价值?
(我认为这是不可能的。问,因为有人主张!)
什么x的值,这两个语句将被执行?
块引用>有没有这样的价值:要么值计算结果为
真正
,或将其计算结果为假$ C(东西!= 0) $ C>)(0)。没有其他可能的值存在。
我知道我们可以执行的if-else在一起,就像这样:if(1){转到ELSE; }其他{ELSE:}
块引用>这工作,但它不依赖的
如果
条件的值都没有。In C or C++
if ( x ) statement1; else statement2;
For what value of
x
will both statements be executed?I know we can execute
if-else
together like this:if(1){ goto ELSE; } else{ ELSE: }
Is there any way, like a value? (Which I think is not possible. Asking because someone is arguing!)
解决方案for what value of x both statements will be executed?
There is no such value: either the value evaluates to
true
(something != 0), or it evaluates tofalse
) (0). No other possible values exist.I know we can execute if-else together like this: if(1){ goto ELSE; } else{ ELSE: }
That works but it isn’t depending of the value of the
if
condition at all.这篇关于如果和其他两个区块同时执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!