C++ Competition Daily Problem – Day 824

Today is the 824th day of learning programming with a slightly cold rain!

Hello, everyone! This is the CSP 2024 Group J Preliminary Exam Questions.

Day 824

C++ Competition Daily Problem - Day 824C++ Competition Daily Problem - Day 824

CSP 2024 Group J Preliminary Exam Questions

Read the Program

2. Read the Program (The program input does not exceed the defined range of arrays or strings; for true/false questions, fill in √ for correct and ⨉ for incorrect; unless otherwise specified, true/false questions are worth 1.5 points, multiple-choice questions are worth 3 points, totaling 40 points)

Question 3

C++ Competition Daily Problem - Day 824

True/False Questions

1. When the input is 2 3, the return value of customFunction(2, 3) is 64. ( )

2. (This question is incorrect; please select both [Correct] and [Incorrect] to receive corresponding points) When b is a negative number, customFunction(a, b) will enter infinite recursion. ( )

3. (This question is incorrect; please select both [Correct] and [Incorrect] to receive corresponding points) As the value of b increases, the program’s runtime becomes longer. ( )

Multiple Choice Questions

1. When the input is 5 4, the return value of customFunction(5, 4) is ( ).

A. 5

B. 25

C. 250

D. 625

2. If the input is x=3 and y=3, the final output of the program is ( ).

A. 27

B. 81

C. 144

D. 256

3. If the customFunction function is changed to return a + customFunction(a-1, b-1); and the input is 3, the final output of the program is ( ).

A. 9

B. 16

C. 25

D. 36

Answers:

START OF SPRING

Solution: This question tests the use of functions in C++.

True/False Questions

1. X

Explanation: The function customFunction is supposed to return b+1 instances of a, so the return value should be 8, not 64, hence it is incorrect.

2. V

Explanation: If b is negative, this question should lead to infinite recursion, but it will eventually cause a stack overflow, so it does not actually result in infinite recursion.

3. V

Explanation: As the value of b increases, the number of iterations increases. Therefore, the program’s runtime becomes longer. However, there may also be cases of integer overflow.

Multiple Choice Questions

1. B

Explanation: The result of adding b instances of a is 25, so choose B.

2. C

Explanation: The result of adding b instances of a is 4 instances of 3, resulting in 12, and the final result includes a pow function, leading to 144.

3. D

Explanation: After the change, the code logic becomes 3+2+1+0 squared, which is 36. Choose D.

C++ Competition Daily Problem - Day 824

20

25

8

C++ Competition Daily Problem - Day 824

AUGUST

Day

Monday

Tuesday

Wednesday

Thursday

Friday

Saturday

1

Army Day

2

9th

3

10th

4

11th

5

12th

6

13th

7

Beginning of Autumn

8

National Fitness Day

9

Last Fub

10

17th

11

18th

12

19th

13

20th

14

21st

15

22nd

16

23rd

17

24th

18

25th

19

Doctor’s Day

20

27th

21

28th

22

29th

23

End of Heat

24

2nd

25

3rd

26

4th

27

5th

28

6th

29

Qixi Festival

30

8th

31

9th

@秀米XIUMI

With a slightly cold rain

Open Wisdom Station

C++ Competition Daily Problem - Day 824

Leave a Comment