历年CSP-J初赛真题解析 | 2020年CSP-J初赛单项选择题(1-15)

学习C++从娃娃抓起!记录下CSP-J备考学习过程中的题目,记录每一个瞬间。

附上汇总贴:历年CSP-J初赛真题解析 | 汇总_csp历年真题_热爱编程的通信人的博客-CSDN博客


1、在内存储器中每个存储单元都被赋予一个唯一的序号,称为( )。

A.地址

B.序号

C.下标

D.编号

【答案】:A

【解析】

数据存储在内存中,使用地址作为序号来查找

2、编译器的主要功能是( A )。

A.将源程序翻译成机器指令代码

B.将源程序重新组合

C.将低级语言翻译成高级语言

D.将一种高级语言翻译成另一种高级语言

【答案】:A

【解析】

编译器的功能就是将高级语言转换为低级机器语言,如汇编语言,选A

3、设x=true,y=true, z=false,以下逻辑运算表达式值为真的是( )。

A.(y∨z)∧x∧z

B.x∧(z∨y)∧z

C.(x∧y)∧z

D.(x∧y)∨(z∨x)

【答案】:D

【解析】

∨表示逻辑或,∧表示逻辑与。A、B、C计算出来都是false,选D

4、现有一张分辨率为2048x1024像素的32位真彩色图像。请问要存储这张图像,需要多大的存储空间?( )。

A.16MB

B.4MB

C.8MB

D.32MB

【答案】:C

【解析】

(2048*1024*32) / (8*1024*1024) = 8,选C

5、冒泡排序算法的伪代码如下:

输入:数组L,n≥1。输出:按非递减顺序排序的L。

算法BubbleSort:

1. FLAG ← n  //标记被交换的最后元素位置
2. while FLAG > 1 do 
3.   k ← FLAG - 1
4.   FLAG ← 1
5.   for j=1 to k do 
6.     if L(j) > L(j+1) then do 
7.       L(j) ↔ L(j+1)
8.       FLAG ← j

对n个数用以上冒泡排序算法进行排序,最少需要比较多少次?( )。

A.n²

B.n-2

C.n-1

D.n

【答案】:C

【解析】

第6行出现了比较,要算一共比较了多少次,就要判断双重循环一共执行了多少次。第4行将FLAG改为了1,所以while循环只会执行一次,故比较次数由for循环决定。for循环执行k次,k=n-1,所以选C

6、设A是n个实数的数组,考虑下面的递归算法:

XYZ(A[1..n])
1. if n=1 then return A[1]
2. else temp ← XYZ(A[1..n-1])
3.   if temp<A[n]
4.   then return temp 
5.   else return A[n]

请问算法XYZ的输出是什么?( )。

A.A数组的平均

B.A数组的最小值

C.A数组的中值

D.A数组的最大值

[Answer]: B

【Analysis】

When n==1 in the first line, it means that there is only one number in the array, and the number is returned. Otherwise, assign the first n-1 numbers to temp, and then compare temp with n (the last number). Lines 3 to 5 indicate that the smaller number is returned after each comparison. So choose B, this function is to find the minimum value.

7. The characteristics that linked lists do not have are ( ).

A. Random access to any element

B. No need to estimate storage space in advance

C. Insertion and deletion do not require moving elements

D. The space required is proportional to the length of the linear table

【Answer】:A

【Analysis】

A linked list cannot randomly access any element, so choose A. I have taken this question in the past few years, and it is recommended to memorize it mechanically.

8. An undirected graph with 10 vertices should have at least ( ) edges to ensure that it is a connected graph.

A.9

B.10

C.11

D.12

【Answer】:A

【Analysis】

For example, 3 points need 2 edges to connect them.

9. The binary number 1011 is converted into a decimal number ( ).

A.11

B.10

C.13

D.12

【Answer】:A

【Analysis】

2^3+2^1+2^0 = 11

10. Five children stand side by side in a row. Two of the children are twins. If the two twins are required to be adjacent, are there ( ) different ways to arrange them?

A.48

B.36

C.24

D.72

【Answer】:A

【Analysis】

The twins are bundled together and seen as a whole. Therefore, 4 children are arranged in a total of 4*3*2*1=24, and twin children can be arranged in 2 ways, so 24*2=48. You can also use the space insertion method. There are 3*2*1=6 ways for the 3 children except the twins. There are 4 ways for the 4 spaces around them. Finally, there are 2 ways for the twins to be arranged, so 6*4*2=48 .

11. The data structure used in the figure below is ( ).

A.Stack

B.Queue

C.Binary tree

D. Hash table

【Answer】:A

【Analysis】

Typical stack push and pop diagram

12. The height of a single-rooted tree is 1. The height of a complete binary tree with 61 nodes is ( D ).

A.7

B.8

C.5

D.6

【Answer】:

【Analysis】

2^(n-1) -1 < The number of complete binary tree nodes < 2^n -1. From this, the height is calculated to be 6, choose D

13. The chronological method of stems and branches is a traditional Chinese chronology method, which consists of 10 celestial stems and 12 earthly branches to form 60 celestial stems and earthly branches. From the Gregorian calendar year, the corresponding celestial stems and earthly branches can be converted according to the following formulas and tables.

Tiangan = (Gregorian calendar year) divided by 10 to obtain the remainder

Earthly Branches = Remainder of (Gregorian calendar year) divided by 12

For example, this year is 2020. When 2020 is divided by 10, the remainder is 0, and the lookup table shows "geng"; when 2020 is divided by 12, the remainder is 4, and the lookup table shows "zi", so this year is the year of Gengzi.

What were the Heavenly Stems and Earthly Branches in 1949 ( )

A. Jiyou

B.Jihai

C. Ji Chou

D. Ji Mao

【Answer】:

【Analysis】

1949 mod 10 = 9, 1949 mod 12 = 5. So for your own ugliness, choose C

14. The 10 three-good student quotas are allocated to 7 classes. Each class has at least one quota. There are ( ) different allocation plans.

A.84

B.72

C.56

D.504

【Answer】:A

【Analysis】

Using the plug-in board method, there are 9 empty slots for 6 boards, C(9,6) = C(9,3) = (9*8*7) / (3*2*1)

15. There are five pairs of gloves of different colors (a total of 10 gloves, one for each left and right hand), and 6 gloves are taken from them at one time. Are there any (A) different ways to make two pairs of gloves?

A.120

B.180

C.150

D.30

【Answer】:

【Analysis】

Exactly matching two pairs of gloves, you can first pick 2 pairs from 5 pairs of gloves, C(5,2) = 10. There are only 6 ways to pick the 5th, and only 4 ways to pick the 6th. Since there is no requirement for which one to pick first, it needs to be divided by 2 to get 6*4/2 = 12. Finally 10*12=120.

Guess you like

Origin blog.csdn.net/guolianggsta/article/details/132814935