#KG007. 信息素养C++ 2025真题【客观题】

信息素养C++ 2025真题【客观题】

一、【单选题】(每题 5 分)

  1. 在 C++ 中,表示逻辑运算符“或”的是( )。 {{ select(1) }}
  • ||
  • &
  • ==
  • @
  1. 执行下列代码,输入 3,输出结果为( )。
#include <iostream>
using namespace std;

int main(){
    int n;
    cin >> n;
    cout << n - 3;
    return 0;
}

{{ select(2) }}

  • -n
  • 0
  • 9
  • 81
  1. 下列选项中,输出结果为 0 的是( )。 {{ select(3) }}
  • cout << "5 - 5";
  • cout << 5 - 5;
  • cout << 2 * 3;
  • cout << 7 / 2;
  1. 执行下列代码段,输出结果为( )。

    cout << 10 % 3;
    

    {{ select(4) }}

  • 1
  • 2
  • 5
  • 10
  1. 下列不属于 C++ 基本程序框架的是( )。 {{ select(5) }}
  • 头文件
  • 命名空间
  • 主函数
  • 程序开发时间:2025-03-23
  1. 阅读以下程序,输入 1 5,输出结果是( )。

    int a, b;
    cin >> a >> b;
    a += b;
    b *= a;
    cout << a << " " << b << endl;
    

    {{ select(6) }}
  • 1 5
  • 6 5
  • 5 6
  • 6 30
  1. 在 C++ 程序中,可得到四位整数十位数字的表达式是( )。 {{ select(7) }}
  • number / 1000
  • number / 100 % 10
  • number / 10 % 10
  • number % 10
  1. 以下程序功能为对正整数 n 进行数位分离并按逆序打印每一位,①处应填写( )。
#include<iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    while (_⊙_){
        int d = n % 10;
        n /= 10;
        cout << d << " ";
    }
    return 0;
}

{{ select(8) }}

  • n > 0
  • n >= 0
  • n < 0
  • n <= 0
  1. 下面程序输出结果为 “1 4 7 10”,补全①处代码正确的是( )。
#include <iostream>
using namespace std;
int main (){
    for(int i = 1; i <= 10; _⊙_){
        cout << i << " ";
    }
    return 0;
}

{{ select(9) }}

  • i++
  • i *= 2
  • i += 3
  • i * 2
  1. 执行下列代码,输出结果为( )。
for (int i = 1; i <= 5; i++){
    if (i % 2 == 0){
        continue;
    }
    cout << i << " ";
}

{{ select(10) }}

  • 1
  • 2 4
  • 1 3 5
  • 1 2 3 4
  1. 输入一个正整数 n,输出一个 n+1 行特殊的直角三角形,则①处应补充的代码为?( )
int n;
cin >> n;
cout << "*" << endl;
for (int i = 1; i <= n; i++){
    for (int j = 1; _①_; j++){
        cout << "*";
    }
    cout << endl;
}

{{ select(11) }}

  • j <= 2 * i
  • j <= i+1
  • j <= 2 * i - 1
  • j <= 2 * i + 1
  1. 以下程序段输出结果为( )。
int cnt = 0;
for (int i = 0; i < 5; i++){
    for (int j = 0; j < 4; j++){
        for (int k = 0; k < 2; k++){
            cnt++;
        }
    }
}
cout << cnt << endl;

{{ select(12) }}

  • 40
  • 60
  • 90
  • 120
  1. 阅读以下代码,输出的内容是?( )
#include <iostream>
using namespace std;
int main(){
    for(int i = 1; i <= 4; i++){
        for(int j = 5; j >= 1; j--){
            cout << j << " ";
        }
        cout << endl;
    }
    return 0;
}

image

{{ select(13) }}

  • A
  • B
  • C
  • D
  1. 执行以下程序,输入5,输出的结果是?( )。
#include <iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i++){
        ans = ans + i*i;
    }
    cout << ans;
    return 0;
}

{{ select(14) }}

  • 5
  • 0
  • 55
  • 85
  1. 运行以下程序,输入6,输出的结果是?( )
#include <iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    if (n % 2 == 0){
        cout << "QWER";
    }else if (n % 3 == 0){
        cout << "WERQ";
    }else if (n % 5 == 0){
        cout << "ERQW";
    }else{
        cout << "RQWE";
    }
    return 0;
}

{{ select(15) }}

  • QWER
  • WERQ
  • ERQW
  • RQWE

二、【判断题】(每题 5 分)

  1. 在C++中,&&表示逻辑运算符“或”。 {{ select(16) }}
  • 正确
  • 错误
  1. 在C++中 可以通过这种方式定义数组并初始化 int c[3]={1,2,3,4,5}。 {{ select(17) }}
  • 正确
  • 错误
  1. 在C++语言中一维数组的下标是从0开始的。 {{ select(18) }}
  • 正确
  • 错误
  1. 代码段
int i = 5;
while(i > 0){
    i -= 2;
}

最终的值是-1。

{{ select(19) }}

  • 正确
  • 错误
  1. 定义int arr[5];后,执行arr[5]=5不会导致数组越界。 {{ select(20) }}
  • 正确
  • 错误