面試系列8--返回整數(shù)中為1的位數(shù)(優(yōu)化版)

字號:

原題:
     Write the function int bitCount(short input) that takes a short as input and
     returns an int. The function returns the number of bits set in the input
     variable. For instance:
     bitCount(7) --> 3
     bitCount(2543) --> 9
     bitCount(11111) --> 9