=Start=
缘由:
总结、提高需要
正文:
参考解答:
#include <stdio.h> #include <stdlib.h> #include <string.h> /* i = 0 i << 2 = 0 i = 1 i << 2 = 4 1 << 1 = 2 1 << 2 = 4 1 << 3 = 8 */ int main(int argc, char const *argv[]) { int i = 0; printf("i = %d\n", i); i = i << 2; printf("i << 2 = %d\n", i); i = 1; printf("i = %d\n", i); i = i << 2; printf("i << 2 = %d\n\n", i); for (i = 0; i < 3; ++i) { printf("1 << %d = %d\n", i+1, 1 << (i+1)); } return 0; }
参考链接:
Linux C/C++ 运算符:种类、优先级、结合性 #nice
http://blog.csdn.net/guowenyan001/article/details/45049347
http://www.slyar.com/blog/c-operator-priority.html
来谈谈C++ 位运算 & | << >> ^ ~ %
http://www.linuxidc.com/Linux/2014-03/98362.htm
C/C++刁钻问题各个击破-位运算及其应用实例(1) #nice
http://www.linuxidc.com/Linux/2012-01/52082p3.htm
C/C++刁钻问题各个击破
http://blog.csdn.net/w57w57w57/article/category/851799
=END=