AI题库 · GESP-C++八级题库
题目分享 #19742
当输入 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;
}
A
7
B
9
C
9
D
11
AI题库 · 编程考级与信奥赛真题库
查看答案 →
复制链接后可在微信、QQ、小红书等平台粘贴分享;答案与解析在题目页。