真假判断:不是0就是真
三目运算:a>10?printf(“大于10\n”):printf(“小于10\n”);printf()有返回值 ‘:‘两边须有返回值
进制定义八进制 int num=012;print(“%o\n”,num); 占位符o 0x
int a=5;四个字节,每个字节有8位;
00000000 00000000 00000000 00000101
00000000 00000000 00000000 00010001
00000000 00000000 00000000 00010100
位运算:&与 |或 ^异或(满足交换律) ~非 >>右移(补零) <<左移
a^a=0,a^0=a;
a<<b ==a*2b次方
9>>2 除四取整
用位运算进行两数交换
int a,b;
a=a^b;
b=a^b;
a=a^b;
位运算判断奇偶数
int a = 5,b=6;
printf("%d\n",a&b);
if(a&1){
printf("jishu");
}else{
printf("oushu\n");
}
编程脚步第二天之按位运算
原文:http://www.cnblogs.com/miaocunfa/p/4330916.html