int NumOnesInBinary(unsigned int number){ int NumOnes = 0;
while(number){ if(number & 1) NumOnes++; number = number >> 1; }
return number}
Powered by: IT博客 Copyright © Enjoy Life