C++ 判断十进制数的二进制形态有几个1
程序员文章站
2022-07-15 10:55:46
...
#include <bits/stdc++.h>
using namespace std;
void main()
{
int i = 0, index = 7;
while (index)
{
i++;
index = index & (index - 1);
}
cout << i;
}