Junior — Senior
Function Behavior Analysis
livecode
Task condition
It is necessary to find out what the function f does and what it can be used for.
#include <iostream>
int f(int x) {
int count = 0;
while (x) {
count++;
x = x & (x - 1);
}
return count;
}
int main() {
std::cout << f(11) << std::endl;
}