题库 / 3081210. 当输入 2023 时,下列程序的输出结果为(2025-12)
3081210. 当输入 2023 时,下列程序的输出结果为(2025-12)
题目描述
当输入 2023 时,下列程序的输出结果为()。
#include <iostream>
using namespace std;
int main() {
int x, ans = 0;
cin >> x;
while (x != 0) {
x -= x & -x;
ans++;
}
cout << ans << endl;
return 0;
}
作答说明
单选题:在选项里选出唯一正确的一项,提交后立即判定。答对得满分,答错可以重新提交(两次提交之间需要间隔 20 秒)。
题目来源
CCF GESP 2025 年 12 月认证 C++ 8 级试题,第 14 题。