本文介绍了这是什么片code的做,什么也各自使用的符号是什么意思?使用的语言是C,我只是个初学者编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

跨code,而我不明白这两条线是做来了。拿不拿的语法。请具体说明是什么类型的功能已被使用像如我猜测,出现了第一行使用条件运算符。

 无符号长长base_size = B> = 2? (B-2)/ 2:0;
的printf(%LLU \\ n,(base_size *(base_size + 1))/ 2);


解决方案

由于每的是C,第一行是有效的。

 无符号长长base_size =(B> = 2(B-2)/ 2:0);

现在,在除权pression()使用的或有条件的运营商。

由于每 C11 标准,章节6.5.15,语法是

 有条件-EX pression:
                    逻辑或-EX pression
                    逻辑或-EX pression?前pression:有条件-EX pression

和语义是[关注我的重点]

So, following that, your case,

b >= 2 ? (b-2)/2:0 

first, the first expression, b >= 2 is evaluated. if b has value greater than or equal to 2, it returns 1, otherwise, 0.

  • if it evaluates to 1, the second operand, (b-2)/2 is executed and the final result of the conditional operator is the value of the expression.

  • similarly, it evaluates to 0, the third operand 0 is returned as the result of the conditional operator.

Finally, the return value of the ternary operator is used to initialize the unsigned long long base_size variable.

About the second line, printf() is a standard C library function, prototyped in stdio.h. You can find more on this here.

这篇关于这是什么片code的做,什么也各自使用的符号是什么意思?使用的语言是C,我只是个初学者编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 16:44