Hello, everyone! Starting today, I will bring you an analysis of the GESP-C++ Level 3 exam questions. The reason it’s Level 3 is that you have successfully passed Level 1 with a high score! I hope that through this sharing, you can suddenly understand a common mistake that is useful!Here, I will not provide answers to programming questions, but I will highlight important points or thought processes. If you have any questions, feel free to comment, and if you’re in a hurry, you can also add my personal WeChat (ldw_0711) to inquire.To begin with, I hope you can complete the exam according to the time requirements before checking the analysis!How to obtain the exam questions:
Through the file shared on the cloud: 2024 GESP C++ Level 3 March Exam Questions (without answers).pdf
Link: https://pan.baidu.com/s/1fWpFzGsQXfVEdO_iKTGpvA?pwd=ldw0 Extraction Code: ldw0
1. Multiple Choice Questions
1.-5:
0000 0000 0000 0101
1111 1111 1111 1010
1111 1111 1111 1011
FFFB
The answer is D
2.-4 Convert to hexadecimal:
1. Find the absolute value
0000 0000 0000 0100
2. Find the one’s complement
1111 1111 1111 1011
3. Add 1
1111 1111 1111 1100 12
fffc
The answer is C
3.00011|10000=10011=19
The answer is C
4.
The answer is B
5.10+48*3=154
The answer is C
6. Any number divisible by 2 or 3 remains unchanged
The answer is C
7. After the last loop ends, the value of i is 20
The answer is A
8. To convert a lowercase character to its corresponding uppercase character, you need to reduce the difference between the characters ‘A’ and ‘a’, which is -32
The answer is C
9. There is no additional judgment at the end
The answer is C
10.
100
7*8+5=61
7*16=112
6*16=96
The answer is C
11.20+19 ×
19+18 √
It is to determine how many pairs of adjacent numbers do not sum to a multiple of 3
The answer is D
12.4
The answer is A
13.00011|10000=10011=19
The answer is B
14. Harmony Operating System
The answer is C
15. Mr. Wang Xuan – Inventor of the Chinese Character Laser Typesetting System
The answer is C
2. True or False Questions
1. The original and complement of a positive number are the same
The answer is ×
2. This is a left shift, and the assignment is =
The answer is ×
3. Exhaustive search requires conditional judgment; this is iteration
The answer is ×
4. Unsigned integers require no overflow; signed integers (positive) require no overflow; signed integers (negative) are not equal
The answer is ×
5. 010 is octal, 010<<1=10 or 16
The answer is ×
6. find(string) finds the index of the first specified string
The answer is √
7. The size of a character array is fixed at the time of definition
The answer is ×
8.
The answer is √
9. Setting an IP address and connecting to a wireless network are common steps to connect to a router
The answer is √
10. Any for loop can be converted to an equivalent while loop; for loops and while loops are functionally equivalent.
The answer is √
3. Programming Questions
Reminder: For programming questions, I think it’s best for you to have your own thoughts and ideas first. Of course, you can refer to my ideas. If anyone needs the specific code, I will consider posting it in the comments.
1. Letter Sum (2024 GESP C++ Level 3 March Question 1)
Problem Description
Student Xiao Yang invented a new type of password. For each lowercase letter, it represents a positive integer, which is its position in the alphabet.
For example, the letter ‘a’ represents the positive integer 1, and the letter ‘b’ represents the positive integer 2; for each uppercase letter, it represents a negative integer, which is the negative value of its ASCII code, for example, the letter ‘A’ represents the positive integer -65.
Student Xiao Yang used this method to encrypt an integer and obtained a string composed of uppercase and lowercase letters. The total sum of the numbers represented by each letter in this string is the integer before encryption.
For example, ‘aAc’ corresponds to the integer before encryption as 1 + (-65) + 3 = -61. For the given string, please calculate the corresponding integer before encryption.
Input
The first line: a positive integer n, representing the number of letters in the string. The second line: a string T composed of uppercase and lowercase letters, representing the encrypted string.
Output
Output: one line with an integer representing the integer before encryption.
Sample Input
3
aAc
Sample Output
-61
[Solution Idea]
Character Interval: Suppose a character variable c,
Lowercase value: c – ‘a’ + 1
Uppercase value: -(c – ‘A’ + 65)
[Knowledge Points] Strings, Loops
2. Perfect Square (2024 GESP C++ Level 3 March Question 2)
Problem Description
Student Xiao Yang has a sequence A containing n non-negative integers,
and he wants to know how many pairs of index combinations <i,j> (1<=i,j<=n,i<j) exist such that Ai + Aj is a perfect square.
If x is a perfect square, there exists a non-negative integer y such that y*y = x.
Input
The first line is a non-negative integer n, representing the number of non-negative integers.
The second line contains n non-negative integers A1 A2 … An, representing the non-negative integers in sequence A.
Output
Output a non-negative integer representing the number of pairs of non-negative integers whose sum is a perfect square.
Sample Input
5
1 4 3 3 5
Sample Output
3
[Solution Idea]
It is simply a loop + judgment to enumerate
[Knowledge Points] Arrays, Loops
In Conclusion
If you are interested or are also learning programming, feel free to add Lazy King’s personal WeChat (ldw_0711). I hope to provide some help on your programming journey!