public static int count(int n){
if(n<0 || n>255){
return -1;
}
int count = 0;
while(n>0){
int temp = n & 1;
if(temp == 1){
count++;
}
n = n >>> 1;
}
return count;
}二进制序列有多少个1
最新推荐文章于 2023-03-25 17:15:42 发布
public static int count(int n){
if(n<0 || n>255){
return -1;
}
int count = 0;
while(n>0){
int temp = n & 1;
if(temp == 1){
count++;
}
n = n >>> 1;
}
return count;
}
被折叠的 条评论
为什么被折叠?