题目
视频
代码
#include<bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while(t--) {
int x, cnt = 0;
cin >> x;
while (x) {
x -= x & (-x);
++cnt;
}
cout << cnt << " ";
}
return 0;
}
欢迎分享,引用。若转载,请联系我,谢谢配合。 本文地址:https://qoogle.top/xiaoxu-tutorial-bas-the-number-of-one-in-binary/