==nba==最新nba篮球赛赛可以告诉下吗>>>

连接中,请稍候……Given by a colleague as a puzzle, I cannot figure out how this C program actually compiles and runs. What is this &&&= operator and the strange 1P1 literal? I have tested in Clang and GCC. There are no warnings and the output is "???"
#include &stdio.h&
int main()
int a[2]={ 10, 1 };
while( a[ 0xFULL?'\0':-1:&&&=a&:!!0X.1P1 ] )
printf("?");
解决方案 The line:
while( a[ 0xFULL?'\0':-1:&&&=a&:!!0X.1P1 ] )
contains the
:& and &:, which translate to ] and [ respectively, so it's equivalent to:
while( a[ 0xFULL?'\0':-1 ] &&= a[ !!0X.1P1 ] )
The literal 0xFULL is the same as 0xF (which is hex for 15); the ULL just specifies that .
In any case, as a boolean it's true, so 0xFULL ? '\0' : -1 evaluates to '\0', which is a
whose numerical value is simply 0.
Meanwhile, 0X.1P1 is a
equal to 2/16 = 0.125.
In any case, being non-zero, it's also true as a boolean, so negating it twice with !! again produces 1.
Thus, the whole thing simplifies down to:
while( a[0] &&= a[1] )
The operator &&= is a
that bit-shifts its left operand right by the number of bits given by the right operand, and returns the result.
In this case, the right operand a[1] always has the value 1, so it's equivalent to:
while( a[0] &&= 1 )
or, equivalently:
while( a[0] /= 2 )
The initial value of a[0] is 10.
After shifting right once, it become 5, then (rounding down) 2, then 1 and finally 0, at which point the loop ends.
Thus, the loop body gets executed three times.
本文地址: &
一个同事作为一个谜给定,我想不通这个C程序实际上是如何编译和运行。这是什么>>> = 运营商和陌生 1P1 文字?我在锵和GCC测试。没有警告,输出为“???” 的#include<&stdio.h中GT;诠释的main(){
诠释一个[2] = {10,1};
而(A [0xFULL'\\ 0': -
1:>>> = A LT;:!! 0X.1P1])
的printf(“?”);
返回0;} 解决方案 行: 而(A [0xFULL'\\ 0': -
1:>>> = A LT;:!! 0X.1P1]) 包含 :> 和< ,它转化为] 和 [分别,所以它的相当于: 而(A [0xFULL'\\ 0': -
1]>&GT = A [!! 0X.1P1]) 字面 0xFULL 相同 0xF的(这是16进制 15 );在 ULL 只是指定。在任何情况下,作为一个布尔这是真的,那么 0xFULL? '\\ 0':-1 计算结果为'\\ 0',这是一个的,其数值仅仅是 0 。同时, 0X.1P1 是的等于2/16 = 0.125。在任何情况下,是不为零,它也确实是一个布尔值,所以用 !! 又产生 1 。因此,整个事情简化到: 而(A [0]>&GT = A [1]) 运营商>> = 是一个的该比特移位其左操作数,并返回结果。在这种情况下,右边的操作数 A [1] 总是 1 ,所以它相当于值: 而(A [0]>> = 1) 或等价地: 而(A [0] / = 2) 的初始值 A [0]
10。一旦权转移后,成为5,那么(四舍五入)2,然后1,最后0时,而此时循环结束。因此,循环体被执行三次。
本文地址: &
扫一扫关注官方微信HQ&&http://t.cn/RbD9Eov ???
160130 ZEEP TOUR IN Osaka #Jackson #?? ? HQ&&/14 #人氣歌謠MC王嘉爾##王嘉爾Jackson##拜託了冰箱MC王嘉爾#
? ?? ?? ?? ???? ?? ???? ???? ???? ?? ??
同時轉發到微博
微博廣場:
認證合作:
關於微博:
關注我們:

我要回帖

更多关于 美国nba篮球赛直播 的文章

 

随机推荐