什么结肠在C呢? [英] what does the colon do in c?
本文介绍了什么结肠在C呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我得到在课堂这个例子中,我不确定它做什么。据我所知,结肠增添了几分场,但我仍然不确定这个问题:
A = B> 0? 3:1;
解决方案
:
运算符称为条件运算符
如果 B
值为> 0
,该值 3
分配给 A
其他值 1
分配给 A
。
把你Kernighan的&放大器;里奇书第二版,2.11章有条件前pressions,操作者的行为进行说明。
I was given this example in class and I am unsure what it does. I understand the colon adds a bit-field, but I am still uncertain about this question:
a = b > 0 ? 3:1;
解决方案
?:
operator is called the conditional operator.
If b
value is > 0
, the value 3
is assigned to a
else the value 1
is assigned to a
.
Take your Kernighan & Ritchie book 2nd edition, chapter 2.11 Conditional expressions, the behavior of the operator is explained.
这篇关于什么结肠在C呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文