我需要一个这样的函数:
// return true iff 'n' is a power of 2, e.g. // is_power_of_2(16) => true is_power_of_2(3) => false bool is_power_of_2(int n);
任何人都可以建议我怎么写这个?你能告诉我一个可以找到这种算法的好网站吗?
c++ algorithm bit-manipulation
algorithm ×1
bit-manipulation ×1
c++ ×1