#3808. GESP1MONI02

GESP1MONI02

GESP1MONI02 GESP C++ 1~2 级模拟卷 · 填空题

本卷共 25 道填空题,每题 2 分,满分 50 分。 请在每题的横线处(输入框内)填写答案。


1. 阅读程序,输出结果是____(两个整数之间用一个空格隔开)。

int a = 0, b = 0;
if (a++ && b++) { }
cout << a << ' ' << b;

{{ input(1) }}


2. 阅读程序,输出结果是____(两个整数之间用一个空格隔开)。

int a = 1, b = 1;
if (a++ || b++) { }
cout << a << ' ' << b;

{{ input(2) }}


3. 二进制数 1011 对应的十进制数是____。

{{ input(3) }}


4. 阅读程序,输出结果是____。

int s = 0;
for (int i = 1; i <= 5; i++) {
    for (int j = 1; j <= i; j++) {
        s = s + j;
    }
}
cout << s;

{{ input(4) }}


5. 阅读程序,输出结果是____(两个整数之间用一个空格隔开)。

int s = 0, cnt = 0;
for (int i = 1; i <= 20; i++) {
    if (i % 3 != 0) continue;
    if (i % 5 == 0) break;
    s = s + i;
    cnt++;
}
cout << s << ' ' << cnt;

{{ input(5) }}


6. 阅读程序,输出结果是____。

int s = 0;
for (int i = 1; i <= 5; i++) {
    for (int j = 1; j <= 5; j++) {
        if ((i + j) % 3 == 0) continue;
        s++;
    }
}
cout << s;

{{ input(6) }}


7. 阅读程序,输出结果是____。

int n = 1, s = 0;
while (n * n <= 100) {
    s = s + n * n;
    n++;
}
cout << s;

{{ input(7) }}


8. 在 C++ 中,要判断整型变量 xx 的值是否在 10 到 20 之间(不含 10 和 20),正确的表达式是____(请用 && 连接两个关系表达式)。

{{ input(8) }}


9. 阅读程序,输出结果是____。

int a = 2, b = 3;
cout << (!a || b % 2 && a < b);

{{ input(9) }}


10. 阅读程序,输出结果是____。

int n = 1000, cnt = 0;
while (n > 1) {
    if (n % 2 == 0) n = n / 2;
    else n = n - 1;
    cnt++;
}
cout << cnt;

{{ input(10) }}


11. 阅读程序,输出结果是____。

int s = 1;
for (int i = 1; i <= 6; i++) {
    if (i % 2 == 0) s = s * i;
    else s = s + i;
}
cout << s;

{{ input(11) }}


12. 执行下列程序,输出结果是____。

char c = 'A';
c = c + 2;
cout << c;

{{ input(12) }}


13. 执行语句 int x = 7.9; 之后,变量 x 的值是____。

{{ input(13) }}


14. 执行语句 double y = 9 / 2; 之后,变量 y 的值是____。

{{ input(14) }}


15. 阅读程序,输出结果是____。

int cnt = 0;
for (int i = 1; i <= 200; i++) {
    int t = i, s = 0;
    while (t > 0) {
        s = s + t % 10;
        t = t / 10;
    }
    if (s % 4 == 0) cnt++;
}
cout << cnt;

{{ input(15) }}


16. 下面的程序用来求输入的 10 个整数中,最大值一共出现了多少次。请把程序中横线处的语句补充完整,横线处应填写____。

int mx = -1, cnt = 0;
for (int i = 1; i <= 10; i++) {
    int a;
    cin >> a;
    if (a > mx) {
        mx = a;
        ____;
    } else if (a == mx) cnt++;
}
cout << cnt;

{{ input(16) }}


17. 阅读程序,若输入为 5 和 1 2 3 4 5(第一个数 5 表示后面有 5 个数),则输出结果是____。

int n, s = 0;
cin >> n;
for (int i = 1; i <= n; i++) {
    int a;
    cin >> a;
    if (a % 2 == 1) s = s - a;
    else s = s + a;
}
cout << s;

{{ input(17) }}


18. 执行下列程序后,变量 a 的值是____。

int a = 6;
a *= 2 + 1;

{{ input(18) }}


19. 执行下列程序后,输出结果是____。

int x = 8;
if (x % 2 == 0) x += 1;
else x -= 1;
cout << x;

{{ input(19) }}


20. 阅读程序,输出结果是____。

int x = 8, y = 12;
if (x > y || x % 4 == 0) {
    if (y % 3 == 0 && x < y) x = x + y;
    else x = x - y;
} else {
    x = x * 2;
}
cout << x;

{{ input(20) }}


21. 阅读程序,输出结果是____(三个整数之间用一个空格隔开)。

int a = 0, b = 0, c = 0;
if (++a && ++b || ++c) { }
cout << a << ' ' << b << ' ' << c;

{{ input(21) }}


22. 阅读程序,输出结果是____。

int s = 0, i = 1;
while (i <= 10) {
    if (i % 2 == 0) s = s + i * i;
    else s = s - i;
    i++;
}
cout << s;

{{ input(22) }}


23. 执行下列程序后,变量 s 的值是____。

int s = 0;
for (int i = 1; i <= 3; i++) {
    for (int j = 1; j <= 4; j++) {
        s += 1;
    }
}

{{ input(23) }}


24. 阅读程序,输出结果是____。

int n = 1234, s = 0;
while (n > 0) {
    s = s + n % 10;
    n = n / 10;
}
cout << s;

{{ input(24) }}


25. 调用 C++ cmath 库中的数学函数,表达式 abs(-12) + max(3, 5) 的值是____。

{{ input(25) }}