华为机试题 求最大连续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;
}
}
标签:试题,int,while,long,++,华为,maxC,bit,include 来源: https://www.cnblogs.com/eat-too-much/p/14943177.html