class Solution {
public:
bool isPowerOfFour(int n) {
if(n<=0) return false;
int x=(int)(log2(n)/log2(4));
if(n-pow(4,x)==0) return true;
return false;
}
};
a+b;
class Solution {
public:
int add(int a, int b) {
// 后续用a表示非进位和,b表示进位,当进位为0,则表示计算结束
return b == 0 ? a : add(a^b, (unsigned int)(a&b) << 1);
}
};
a*b
class Solution {
public:
int multiply(int A, int B) {
bool a[A][B];
return (int)sizeof(a);
}
};
我滴ma呀,面试真的会出这种题吗,如果真出这家能是什么公司呀....