题解 | #求最大连续bit数#
求最大连续bit数
https://www.nowcoder.com/practice/4b1658fd8ffb4217bc3b7e85a38cfaf2
#include <stdio.h> int main() { int a, b; int count1=0; int count2=0; scanf("%d",&a); while(a!=0) { if(a%2==1) { count1++; if(count1>count2) count2=count1; } else if(a%2==0) count1=0; a=a/2; } printf("%d",count2); return 0; }