华为机试题 求最大连续bit数

简介

c = c++ ?
c = ++c ?

code

#include <iostream>
#include <string>
using namespace std;
int main() {
    long long n;
    while(cin >> n) {
        bool pre = true;
        int c = 0;
        int t = 128;
        int maxC = 0;
        while(t--){
            c = n & 1 ? ++c : 0;
            if(c > maxC) {
                maxC = c;
            }
            n = n >> 1;
        }
        cout << maxC << endl;
    }
}
Hope is a good thing,maybe the best of things,and no good thing ever dies.----------- Andy Dufresne
原文地址:https://www.cnblogs.com/eat-too-much/p/14943177.html