题目只要求计算出连续,所以倒置二进制数也是可以的。

#include<stdio.h>

int main(int argc, char const *argv[])
{
    int i_num=0;

    while (scanf("%d", &i_num) != EOF)
    {
        int bnumber[9]={0};
        int i=0, max=0, count=0;
        while (i_num!=0)
        {
            bnumber[i] = i_num%2;
            i_num /= 2;
            i++;
        }

        for (int i = 0; i < 9; i++)
        {
            if (bnumber[i] == 1)
            {
                count++;
            }
            else
            {
                count = 0;
            }
            max = max>count?max:count;
        }
        printf("%d\n", max);
    }
    
    
    return 0;
}