思路“num &(num-1)==0 返回true,否者返回false。代码如下:
boolean isPower(int num){ if(num<=0) return false; if((num & (num-1))==0) return true; else return false; }
Powered by: 博客园 Copyright © 2024 骄阳照林 Powered by .NET 9.0 on Kubernetes