“5c7fadae9971618644a9040ce9d127f8e2ed290e”上不存在“python/paddle/git@gitcode.net:RobotFutures/Paddle.git”
提交 b3eb1203 编写于 作者: M Mars Liu

add a exerc

上级 3a25072d
# 数的结构判断
下列代码用于判断一个给定整数 x ,是否是 2 的正整次幂。其中能正确执行的是:
## aop
### before
```
#include <stdio.h>
```
### after
```c
printf("check(%d) return %d\n", 100, check(100));
printf("check(%d) return %d\n", 64, check(64));
printf("check(%d) return %d\n", 2, check(2));
printf("check(%d) return %d\n", 32, check(32));
```
## 答案
```c
bool check(int x) {
if(x < 2){
return 0;
}
return x & (x-1) == 0;
}
```
## 选项
### 没有考虑边界
```c
bool check(int x) {
if(x < 2){
return 0;
}
return x & (x-1) == 0;
}
```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册