如果和其他两个区块同时执行 [英] Simultaneous execution of both if and else blocks

查看:141
本文介绍了如果和其他两个区块同时执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C或C ++

 如果(X)
    语句1;
其他
    语句2;

有关什么的值x 都将语句被执行?

我知道我们可以执行的if-else 起来是这样的:

 如果(1){
    转到ELSE;
}
其他{
    其他:
}

有什么办法,就像一个价值?
(我认为这是不可能的。问,因为有人主张!)


解决方案

  

什么x的值,这两个语句将被执​​行?


有没有这样的价值:要么值计算结果为真正,或将其计算结果为)(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 to false) (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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆