#2573. 2023 CSP-S1 真题 · 阅读程序1

2023 CSP-S1 真题 · 阅读程序1

2023 CSP-S1 真题(120 分钟,总分 100 分)

阅读程序1(共 6 题,共 12.5 分)

1.

#include <iostream>
using namespace std;

unsigned short f(unsigned short x) {
    x ^= x << 6;
    x ^= x >> 8;
    return x;
}

int main() {
    unsigned short x;
    cin >> x;
    unsigned short y = f(x);
    cout << y << endl;
    return 0;
}

假设输入的 x 是不超过 65535 的自然数,完成下面的判断题和单选题:

当输入非零时,输出一定不为零。

{{ select(1) }}

  • 正确
  • 错误

2. 将f函数的输入参数的类型改为unsigned int,程序的输出不变。

{{ select(2) }}

  • 正确
  • 错误

3. 当输入为“65535”时,输出为“63”。

{{ select(3) }}

  • 正确
  • 错误

4. 当输入为“1”时,输出为“64”。

{{ select(4) }}

  • 正确
  • 错误

5. 当输入为“512”时,输出为()。

{{ select(5) }}

  • “33280”
  • “33410”
  • “33106”
  • “33346”

6. 当输入为“64”时,执行完第5行后x的值为()。

{{ select(6) }}

  • “8256”
  • “4130”
  • “4128”
  • “4160”