first asking for an input, and transfer it into binary, then count the number of "1"
int func(x) {
int countx = 0;
while(x) {
countx ++;
x = x&(x-1);
}
return countx;
}
Friday, September 24, 2010
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment