题解 | #求最大连续bit数#
求最大连续bit数
https://www.nowcoder.com/practice/4b1658fd8ffb4217bc3b7e85a38cfaf2
#include <stdio.h>
#include <string.h>
int main(){
int num;
scanf("%d", &num);
int count = 0, max = 0;
while(num != 0){
if((num & 1) == 1){
count++;
max = max > count ? max : count;
}
else{
count = 0;
}
num = num >> 1;
}
printf("%d", max);
return 0;
}
查看8道真题和解析
