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/1.\344\275\215\345\222\214\345\255\227\350\212\202/check.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/1.\344\275\215\345\222\214\345\255\227\350\212\202/check.md" index fbcd09ffa711198925c96b354e402b5f25fec4dc..059c793c51df26dba67bdcccee6333ec1431f786 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/1.\344\275\215\345\222\214\345\255\227\350\212\202/check.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/1.\344\275\215\345\222\214\345\255\227\350\212\202/check.md" @@ -27,7 +27,7 @@ int check(int x) { if(x < 2){ return 0; } - return x & (x-1) == 0; + return (x & (x-1)) == 0; } ``` @@ -38,11 +38,31 @@ int check(int x) { ```c -bool check(int x) { - if(x < 2){ - return 0; - } +int check(int x) { + return (x & (x-1)) == 0; +} + +``` + +### 优先级错误 + +```c + +int check(int x) { return x & (x-1) == 0; } ``` + +### 边界条件处理的不对 + +```c +int check(int x) { + for(int value = x; value > 0; value = value/2) { + if((value % 2) != 0){ + return 0; + } + } + return 1; +} +``` \ No newline at end of file