以下问题均假定输入的 n 为不超过 2^31−1 的非负整数。 将第 11 行的 ++x; 删除后,程序输出的两个数一定相等。( )
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
int x = 1, y = 1;
while (n > 0) {
if (n % 2 == 0) {
++x;
} else {
++x;
++y;
}
n = n / 2;
}
cout << x << ' ' << y << endl;
return 0;
}
正确
错误