题解 | #求最大连续bit数#
求最大连续bit数
http://www.nowcoder.com/practice/4b1658fd8ffb4217bc3b7e85a38cfaf2
#include <stdio.h>
#include <string.h>
int main()
{
int n;
while (scanf("%d", &n) != EOF)
{
int count = 0;
int max = 0;
while (n != 0)
{
while (n % 2 == 1)
{
count++;
n /= 2;
}
if (count > max)
max = count;
count = 0;
n /= 2;
}
printf("%d\n", max);
}
return 0;
}