在别人的代码中看到的,看来还是有一点作用的,代码如下:
#include 
using namespace std;

int quickfindonecnt(int i)
{
	int cnt = 0;
	while (i)
	{
		cnt++;
		i &= i-1;
	}
	return cnt;
}

int main()
{
	int i = 0xFFF;
	cout << quickfindonecnt(i) << endl;
	return 0;
}

相关文章:

  • 2021-11-03
  • 2022-03-15
  • 2021-07-31
  • 2021-09-21
  • 2021-11-01
  • 2021-09-21
  • 2022-12-23
  • 2021-05-09
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-24
  • 2021-10-19
  • 2022-12-23
相关资源
相似解决方案