if else if else 中的else语句的执行情况是什么样的?if(A) {a};else if(B) {b};else if(C) {c};else {d};我比较迷糊的是如果A为真,B和C都为假,a当然会执行了,d会执行吗?如果A和B都为真,C为假,a当然会执行了,b

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/28 00:40:06
if else if else 中的else语句的执行情况是什么样的?if(A)   {a};else if(B)  {b};else if(C) {c};else  {d};我比较迷糊的是如果A为真,B和C都为假,a当然会执行了,d会执行吗?如果A和B都为真,C为假,a当然会执行了,b

if else if else 中的else语句的执行情况是什么样的?if(A) {a};else if(B) {b};else if(C) {c};else {d};我比较迷糊的是如果A为真,B和C都为假,a当然会执行了,d会执行吗?如果A和B都为真,C为假,a当然会执行了,b
if else if else 中的else语句的执行情况是什么样的?
if(A)   {a};
else if(B)  {b};
else if(C) {c};
else  {d};
我比较迷糊的是
如果A为真,B和C都为假,a当然会执行了,d会执行吗?
如果A和B都为真,C为假,a当然会执行了,b会执行吗?d会执行吗?
如果A为假,B和C都为真,是不是因为B在C前面,所以就只执行 d会执行吗?
 
    在这种有多个 else if 的结构中,判断 if(A) 为真后,还会判断 else if 还回执行 else
    并列的多个 else if,是不是从顺序开始,只要有一个else if 为真,就不再判断else if 有else if 为真,会跳过 else  

if else if else 中的else语句的执行情况是什么样的?if(A) {a};else if(B) {b};else if(C) {c};else {d};我比较迷糊的是如果A为真,B和C都为假,a当然会执行了,d会执行吗?如果A和B都为真,C为假,a当然会执行了,b
顺序判断:
(A) is true: -- 无论其它(B,C的状态) 均执行 {a}, 不再管后续的else了;
(A) is false and (B) is true: -- 无论C的任何状态, 均执行 {b}, 不再管后续的else了;
(A) is false and (B) is false and (C) is true: 执行 {c}, 不再管后续的else了;
(A), (B), (C) 均为 false: 执行 {d}