1 #include <iostream>
2 using namespace std;
3
4 #include <stdlib.h>
5 #include <sys/types.h>
6
7 int Count(u_int32_t n)
8 {
9 int count = 0;
10 while (n) {
11 ++count;
12 n = n & (n - 1);
13 }
14 return count;
15 }
16
17 int main()
18 {
19 cout << Count(128) << endl;
20
21 return 0;
22 }
posted on 2011-10-21 13:23  吃吃户  阅读(197)  评论(0编辑  收藏  举报