leetcode-191. 位1的个数
题目:
代码:
#include <iostream>
using namespace std;
int hammingWeight(uint32_t n){
int count=0;
for(int i=0;i<32;i++){
if(n & (1<<i)){
count++;
}
}
return count;
}
int main(){
int count=0;
count = hammingWeight(uint32_t n);
cout<<count;
return 0;
}