一个整数为2的幂说明该整数的二进制中只有一个1. bool isSquareOf2 (int n) { return (n&(n-1))==0?true:false; } 转载于:https://www.cnblogs.com/happygirl-zjj/p/4598878.html