如果x = 10 y = 10 z = 5 x< y< z = true [英] if x=10 y=10 z=5 how is x<y<z=true?
本文介绍了如果x = 10 y = 10 z = 5 x< y< z = true的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个问题&在回答中它说,由于从左到右的关联性,结果将为1,这对于该陈述是正确的。这是代码。
I have this question & in the answer it says that due to left to right associativity the result would be 1 that is true for this statement. This is the code.
#include<stdio.h>
int main ()
{
int i=0,x=10,y=10,z=5;
i=x<y<z;
printf("\n\n%d",i);
return 0;
}
但是x在这里大于z,这是怎么回事?
But x is greater than z here so how is this happening ?
推荐答案
表达式x
The expression x
(x < y) < z
所以它变成了
(10 < 10) < 5
进一步评估为
0 < 5
这是真的。
I认为您想要这样的东西:
I think you wanted something like this:
x < y && y < z
这篇关于如果x = 10 y = 10 z = 5 x< y< z = true的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文