diff --git "a/data/3.C\350\257\255\350\250\200\351\253\230\351\230\266/3.\344\275\215\350\277\220\347\256\227/5.\344\275\215\351\200\273\350\276\221\350\277\220\347\256\227\347\254\246/bit_op.json" "b/data/3.C\350\257\255\350\250\200\351\253\230\351\230\266/3.\344\275\215\350\277\220\347\256\227/5.\344\275\215\351\200\273\350\276\221\350\277\220\347\256\227\347\254\246/bit_op.json" new file mode 100644 index 0000000000000000000000000000000000000000..24fad563ea3280d3f6c59aea1869656ba8f4fcff --- /dev/null +++ "b/data/3.C\350\257\255\350\250\200\351\253\230\351\230\266/3.\344\275\215\350\277\220\347\256\227/5.\344\275\215\351\200\273\350\276\221\350\277\220\347\256\227\347\254\246/bit_op.json" @@ -0,0 +1,5 @@ +{ + "type": "code_options", + "author": "幻灰龙", + "source": "bit_op.md" +} \ No newline at end of file diff --git "a/data/3.C\350\257\255\350\250\200\351\253\230\351\230\266/3.\344\275\215\350\277\220\347\256\227/5.\344\275\215\351\200\273\350\276\221\350\277\220\347\256\227\347\254\246/bit_op.md" "b/data/3.C\350\257\255\350\250\200\351\253\230\351\230\266/3.\344\275\215\350\277\220\347\256\227/5.\344\275\215\351\200\273\350\276\221\350\277\220\347\256\227\347\254\246/bit_op.md" new file mode 100644 index 0000000000000000000000000000000000000000..07b7876bb0525853f1269daa3133e9d4c173fc2c --- /dev/null +++ "b/data/3.C\350\257\255\350\250\200\351\253\230\351\230\266/3.\344\275\215\350\277\220\347\256\227/5.\344\275\215\351\200\273\350\276\221\350\277\220\347\256\227\347\254\246/bit_op.md" @@ -0,0 +1,58 @@ +# 位逻辑运算 + +下列错误的代码是? + +## 答案 + +```c +#include +#include + +int main(int argc, char** argv){ + int i = 1; + assert(i<<1==4); + return 0; +} + +``` + +## 选项 + +### 选项1 + +```c +#include +#include + +int main(int argc, char** argv){ + int i = 2; + assert(i>>1==1); + return 0; +} +``` + +### 选项2 + +```c +#include +#include + +int main(int argc, char** argv){ + int i = 3; + assert((i&2)==2); + return 0; +} +``` + +### 选项3 + +```c +#include +#include + +int main(int argc, char** argv){ + int i = 1; + assert((i|2)==3); + return 0; +} +``` \ No newline at end of file diff --git "a/data/3.C\350\257\255\350\250\200\351\253\230\351\230\266/3.\344\275\215\350\277\220\347\256\227/5.\344\275\215\351\200\273\350\276\221\350\277\220\347\256\227\347\254\246/config.json" "b/data/3.C\350\257\255\350\250\200\351\253\230\351\230\266/3.\344\275\215\350\277\220\347\256\227/5.\344\275\215\351\200\273\350\276\221\350\277\220\347\256\227\347\254\246/config.json" index f13fb2316922c8697a63aeaf334324a1ee7b4027..bafbbeecd1014bbd184e770037bd343b1b8cb755 100644 --- "a/data/3.C\350\257\255\350\250\200\351\253\230\351\230\266/3.\344\275\215\350\277\220\347\256\227/5.\344\275\215\351\200\273\350\276\221\350\277\220\347\256\227\347\254\246/config.json" +++ "b/data/3.C\350\257\255\350\250\200\351\253\230\351\230\266/3.\344\275\215\350\277\220\347\256\227/5.\344\275\215\351\200\273\350\276\221\350\277\220\347\256\227\347\254\246/config.json" @@ -6,5 +6,7 @@ "C语言" ], "children": [], - "export": [] + "export": [ + "bit_op.json" + ] } \ No newline at end of file diff --git "a/data/3.C\350\257\255\350\250\200\351\253\230\351\230\266/3.\344\275\215\350\277\220\347\256\227/7.\344\275\215\345\255\227\346\256\265/bit_field.md" "b/data/3.C\350\257\255\350\250\200\351\253\230\351\230\266/3.\344\275\215\350\277\220\347\256\227/7.\344\275\215\345\255\227\346\256\265/bit_field.md" index 9133d493d7aceb009f7476c41dde0b77fb0b63a6..be5f79eec20775d3dcf48bb6a874dda07dccb0b2 100644 --- "a/data/3.C\350\257\255\350\250\200\351\253\230\351\230\266/3.\344\275\215\350\277\220\347\256\227/7.\344\275\215\345\255\227\346\256\265/bit_field.md" +++ "b/data/3.C\350\257\255\350\250\200\351\253\230\351\230\266/3.\344\275\215\350\277\220\347\256\227/7.\344\275\215\345\255\227\346\256\265/bit_field.md" @@ -1,4 +1,4 @@ -# 十六进制转换 +# 位字段(bit filed) 利用位域,你能声明比字符宽度更小的成员,低至1位。假设机器字是8 bytes,下面的结构体大小是?