Solution to Number Of One In Binary from Jobdu

2 Aug

Question (in Chinese): http://ac.jobdu.com/problem.php?pid=1513

Question Name: Number Of One In Binary

Question Description: Give an integer, check how many 1(s) are there in its binary form.

Input: may contains multiple test cases. The first line indicates how many test cases are there in the following input. Each of the next lines contains one integer as a test case.

Output: the number of 1(s) for each test case.

The challenge should appear in the Elements of Programming Interviews: The Insiders’ Guide. The book is on the way to me. So I cannot make sure.

Leave a Reply

Your email address will not be published. Required fields are marked *

Please put your code into a <pre>YOUR CODE</pre> section. Thanks and Happy Coding!