#include "stdafx.h" int count(int t) { int ret = 0; while(t) { t &= t-1; ret++; } return ret; } int _tmain(int argc, _TCHAR* argv[]) { printf("%d\n",count(1)); printf("%d\n",count(2)); printf("%d\n",count(7)); return 0; }
Powered by: 博客园 Copyright © 2024 KurtWang Powered by .NET 9.0 on Kubernetes