#XXSY2025HNP. 2025C++华南算法创意小学组p

2025C++华南算法创意小学组p

2025C++华南算法创意小学组p

一、单选题(共15题)

1.执行以下程序段,输入30 50,输出的结果为?( )

int a,b; 
cin >> a >> b; 
if(a > b) cout << a; 
else { cout << b; }

{{ select(1) }}

  • 30
  • 50
  • 30 50
  • 无输出

2.执行以下程序,输入56 25,输出的结果是?( )

int a, b; 
cin >> a >> b; 
cout << max(a,b);

{{ select(2) }}

  • 56
  • 25
  • 1000
  • 无输出

3.下列关系运算符,可以用来判断两数相等的是?( )

{{ select(3) }}

  • ==
  • >
  • <=
  • <

4.在C++中,表示逻辑运算符 "或" 的是?( )

{{ select(4) }}

  • ||
  • &
  • ==
  • @

5.下列选项中,输出结果为0的是?( ){{ select(5) }}

  • cout << "5 - 5";
  • cout << 5 - 5;
  • cout << 2 * 3;
  • cout << 7 / 2;

6.现有数组定义为int num[4] = {6}; 则数组num中的元素分别是?( )

{{ select(6) }}

  • 6 6 6 6
  • 0 0 0 0
  • 6 0 0 0
  • 0 0 0 6

7.执行下面程序段,当输入5 1 2 9 8 7,输出的结果为?( )

int n, maxx = 0; 
cin >> n; 
for(int i = 1; i <= n; i++) { 
    int num; 
    cin >> num; 
    maxx = max(maxx,num); 
} 
cout << maxx;

{{ select(7) }}

  • 1
  • 9
  • 8
  • 7

8.执行下列代码,输出结果为?( )

for (int i = 1; i <= 5; i++) {
    if (i % 2 == 0) continue; 
	cout << i << " ";
}

{{ select(8) }}

  • 1
  • 2 4
  • 1 3 5
  • 1 2 3 4

9.在C++程序中,可以得到一个四位整数的十位上的数字的表达式是?( )

{{ select(9) }}

  • number / 1000
  • number / 100 % 10
  • number / 10 % 10
  • number % 10

10.下面程序段输出的结果是?

int array[3] = {4, 5, 6}; 
array[0] = array[0] - 3; 
cout << array[0] << " " << array[1] << array[2];

{{ select(10) }}

  • 4 5 6
  • 1 5 6
  • 4 2 6
  • 4 5 3

11.使用双重for循环结构,求1! + 2! + 3! + 4! …… +n! (1<=n<=10),则①处应补充的代码是?( )

int sum = 0; 
for (int i = 1; i <= n; i++) {
    int mul = 1; 
    for (int j = 1; j <= i; j++) _①_ 
    sum += mul; 
} 
cout << sum << endl;

{{ select(11) }}

  • mul += j;
  • mul *= j;
  • mul *= i;
  • mul += i;

12.阅读程序,当输入7,程序输出的结果为?( )

#include<iostream>
usingnamespacestd;
int main() {
    int n;
    int a[51] = {};
    cin >> n;
    a[1] = 1;
    for(int i = 2; i <= n; i++) {
        a[i] = a[i - 1] * 2 + 1;
    }
    cout << a[n];
    return0;
}

{{ select(12) }}

  • 63
  • 97
  • 115
  • 127

13.现有n(n <= 1000)个人参加军训排队,刚开始的时候,所有人都面向教官站立成一排,每个人手里都拿着一个编号,编号依次为1、2、3、...、n。现在教官想让编号为3的倍数的人向后转,然后再让编号为5的倍数的人再向后转。使用0模拟面向教官,使用数字1模拟背向教官。教官想知道最后还有哪些编号的人依然面向教官,请补全代码。( )

#include<iostream>
int a[1001]; 
usingnamespacestd;
int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        a[i] = 0;
    }
    for (int i = 1; i <= n; i++) { 
        if (i % 3 == 0) {
            a[i] = 1;
        }
        if (i % 5 == 0) {
            a[i] = 1;
        }
    }
    for (int i = 1; i <= n; i++) { 
        if (_①_) {
            _②_
        }
    }
    return0;
}

{{ select(13) }}

  • a[i] == 0 cout << a[i] << " ";
  • a[i] == 0 cout << i << " ";
  • a[i] == 1 cout << a[i] << " ";
  • a[i] == 1 cout << i << " ";

14.以下程序段输出的结果为?( )

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(14) }}

  • 40
  • 60
  • 90
  • 120

15.执行以下程序,输入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(15) }}

  • 5
  • 30
  • 55
  • 85

二、判断题(共5题)

1.执行代码cout << "8 - 2"; 因为双引号里面的内容会原样输出,因此输出结果为8 - 2。( ){{ select(16) }}

  • 正确
  • 错误

2.在C++语言中,一维数组的下标是从0开始。( ){{ select(17) }}

  • 正确
  • 错误

3.定义一个字符数组char s[100];,这个数组最多能存储10000个字符。{{ select(18) }}

  • 正确
  • 错误

4.定义int arr[10];后,执行arr[10] = 5;不会导致数组越界。( ){{ select(19) }}

  • 正确
  • 错误

5.在C++中的循环结构中,可以通过continue结束循环。( )

{{ select(20) }}

  • 正确
  • 错误