https://leetcode.com/problems/power-of-two/description/
题目
Given an integer, write a function to determine if it is a power of two.
题目翻译
题目解析
判断一个数是不是2的幂。
参考答案
class Solution {
public:
bool isPowerOfTwo(int n) {
if(n<=0)
{
return false;
}
return (n&(n-1)) == 0;
}
};