首页 > 试题广场 >

下面 C++ 程序的输出结果为() #include io

[单选题]
下面 C++ 程序的输出结果为()
#include <iostream>
#include <string>
using namespace std;

int compute(int p) {
    int num = 0;
    while(p) {
        num++;
        p = p&(p-1);
    }
    return num;
}

int main(){
    std::cout << compute(9999) << std::endl;
    return 0;
}
  • 7
  • 8
  • 20
  • 编译错误

这道题你会答吗?花几分钟告诉大家答案吧!