public static int numberOf1(int n) {
int count = 0;
while(n != 0) {
count ++;
n = n&(n-1);
}
return count;
}
public static void main(String[] args) {
System.out.println(numberOf1(4));
}
15. 二进制中 1 的个数
最新推荐文章于 2025-12-19 15:39:34 发布
447

被折叠的 条评论
为什么被折叠?



