#XXSY2025HDP. 2025 C++华东算法创意小学组

2025 C++华东算法创意小学组

2025华东算法创意C++小学组

一、单选题(共15题)

1.在C++中,表示逻辑运算符“或”的是()?{{ select(1) }}

  • ||
  • &
  • ==
  • @

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

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

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

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

{{ select(3) }}

  • 30
  • 50
  • 30 50
  • 无输出

4.在C++中,a=a-b可以简写为a-=b。执行下列代码,输出结果为()?

int a=10;
a-=9;
cout<<a;

{{ select(4) }}

  • 2
  • -6
  • 9
  • 1

5.下列选项中,可以判断变量n为偶数的是?(){{ select(5) }}

  • n%1==0
  • n%2==0
  • n%5==0
  • n%7==0

6.执行以下程序,输出的结果是?

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

{{ select(6) }}

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

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

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

8.以下程序的功能是对一个正整数 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

9.阅读以下程序,输入1 5,输出的结果是?

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

{{ select(9) }}

  • 1 5
  • 6 5
  • 5 6
  • 6 30

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

char upper='A';
char lower=upper+32;
cout<<lower;

{{ select(10) }}

  • A
  • a
  • 65
  • 97

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

  • 5
  • 30
  • 55
  • 85

12.使用双重 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(12) }}

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

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

#include<iostream>
using namespace std;
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];
	return 0;
}

{{ select(13) }}

  • 63
  • 97
  • 115
  • 127

14.运行以下程序,输出的结果是?

int a[6]={1,2,3,4,5,6};
for(int i=0;i<=5;i++){
    cout<<a[i]<<"+";
}

{{ select(14) }}

  • 1 2 3 4 5 6
  • 1+2+3+4+5+6+
  • 1+2+3+4+5+6
  • 1,2,3,4,5,6,

15.现有 n(n <= 1000)个人参加军训排队,刚开始的时候,所有人都面向教官站立成一排,每个人手里都拿着一个编号,编号依次为1、2、3、...、n。

​ 现在教官想让编号为 3 的倍数的人向后转,然后再让编号为 5 的倍数的人再向后转。使用 0 模拟面向教官,使用数字 1模拟背向教官。 教官想知道最后还有哪些编号的人依然面向教官,请你帮忙补全代码。下列选项中哪一项正确?()

#include<iostream>
using namespace std;
int a[1001];
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(__①__){
			__②__;
		}
	}
	return 0;
}

{{ select(15) }}

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

二、判断题(共5题)

1.在C++中,bool类型是用来存储小数的。{{ select(16) }}

  • 正确
  • 错误

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

  • 正确
  • 错误

3.在C++中,一维数组里元素的值可以相等。{{ select(18) }}

  • 正确
  • 错误

4.一个质数的因数个数一定是2个。{{ select(19) }}

  • 正确
  • 错误

5.代码段:

int i=5;
while(i>0){
    i-=2;
}

最终i的值是-1。

{{ select(20) }}

  • 正确
  • 错误