C++求最大连续bit数

求最大连续bit数

http://www.nowcoder.com/questionTerminal/4b1658fd8ffb4217bc3b7e85a38cfaf2

#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int n;
    while(cin >> n) {
        int cnt = 0;
        while(n) {
            n = n&(n<<1);
            cnt++;
        }
        cout << cnt << endl;
    }
    return 0;
}
全部评论

相关推荐

09-13 08:41
服装/纺织设计
那一天的Java_J...:你第一次参加面试吗
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务