Technology Sharing

June 2024 CCF-GESP Programming Ability Level C Programming Level 3 Exam Questions Analysis

2024-07-12

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

This article is included in the column "C++ Level Certification CCF-GESP Real Questions Analysis”, column directory:click here. After subscribing, you can read all the articles in the column.

I. Multiple choice questions (2 points each, 30 points in total)

Question 1

Xiao Yang's parents took him to a training institution to register him for the Level 1 GESP certification exam organized by CCF. He can choose from () certification languages.
A. 1
B. 2
C. 3
D. 4

Answer: C

Question 2

In the following flowchart, when yr is input as 2024, it can be determined that yr represents a leap year and the output is that February has 29 days. In this case, the diamond box in the figure should be filled in with ( ).
insert image description here

A. (yr%400==0) || (yr%4==0)
B. (yr%400==0) || (yr%4==0 && yr%100!=0)
C. (yr%400==0) && (yr%4==0)
D. (yr%400==0) && (yr%4==0 && yr%100!=0)

Answer: B

Question 3

It is generally defaulted that integer variables (int) in 64-bit computer systems are still 32 bits, so the data range that integers can represent is ( ).
A. 0 0 0 ~ 2 32 2^{32} 232
B. 0 0 0 ~ 2 64 2^{64} 264
C. − 2 31 -2^{31} 231 ~ ( 2 31 ) − 1 (2^{31})-1 (231)1
D. − 2 63 -2^{63} 263 ~ ( 2 63 ) − 1 (2^{63})-1 (263)1

Answer: C

Question 4

The following code converts decimal into octal, so the blank should be filled in with ( ).

#include <iostream>

using namespace std;

void decimal2octal(int decimal) {
	int oct_number[100];
	int i = 0;
	
	while (decimal > 0) {
		__________________________ //在此处填入代码
	}
	for (int j = i - 1; j >= 0; j--) {
		cout << oct_number[j];
	}
	cout << endl;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

A. oct_number[i] = decimal % 8; decimal /= 8;
B. oct_number[i] = decimal / 8; decimal %/= 8;
C. oct_number[i++] = decimal % 8; decimal /= 8;
D. oct_number[i++] = decimal / 8; decimal %= 8;

Answer: C

Question 5

The decimal number corresponding to the binary number 101.11 is ( ).
A. 6.5
B. 5.5
C. 5.75
D. 5.25

Answer: C

Question 6

The output result of the following flowchart is ( ).
insert image description here

A. 5
B. 10
C. 20
D. 30

Answer: B

Question 7

The output result of the following code is ( ).

#include <iostream>
using namespace std;

int main() {
	int a = 12;
	int result = a >> 2;
	cout << result << endl;
	return 0;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

A. 12
B. 6
C. 3
D. 1

Answer: C

Question 8

The output result of the following code is ( ).

#include <iostream>
using namespace std;

int main() {
	int a = 5;
	int b = 10;
	
	a = a ^ b;
	b = a ^ b;
	a = a ^ b;
	
	cout << "a = " << a << ", b = " << b << endl;
	return 0;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

A. a = 5, b = 10
B. a = 5, b = 5
C. a = 10, b = 5
D. a = 10, b = 10

Answer: C

Question 9

If the string is defined as char str[] = "GESP";, the length of the character array str is ( ).
A. 0
B. 4
C. 5
D. 6

Answer: C

Question 10

Filling in the blanks ( ) in the following code will result in the output being "7".

#include <iostream>
using namespace std;

int main() {
	int array[5] = {37524};
	
	int max = 0;
	for(int i=0; i<5; i++)
		if(______________) // 在此处填入代码
			max = array[i];
			
	cout << max << endl;
	return 0;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

A. max > array[i]
B. max < array[i]
C. max = array[i]
D. None of the above

Answer: B

Question 11

Xiao Yang is doing a math problem. The problem requires finding a number from 1 to 35 that is divisible by 7, that is, [7, 14, 21, 28, 35]. Which code should be filled in the blank? ( )

#include <iostream>
using namespace std;

int main() {
	int arr[35];
	int count = 0;
	for (int i = 1; i <= 35; i++) {
		if (i % 7 == 0)
			__________________________ // 在此处填入代码
	}
	for (int i = 0; i < count; i++)
		cout << arr[i] << endl;
	return 0;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

A. arr[count++] = i;
B. arr[i] = count++;
C. arr[i] = count;
D. arr[count] = count++;

Answer: A

Question 12

It is known that the decimal representation of the ASCII code of the character '0' is 48. After executing the following C++ code, the output is ( ).

#include <iostream>
using namespace std;

int main() {
	string s = "0629";
	
	int n = s.length();
	int x = 0;
	for(int i = 0; i < n; i++)
		x += s[i];
		
	cout << x << endl;
	return 0;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

A. 17
B. 158
C. 209
D. 316

Answer: C

Question 13

A primary school boys' basketball team is recruiting new members, requiring members to be at least 135 cm tall (not including 135 cm). There are 10 people who signed up this time, and their heights are 125, 127, 136, 134, 137, 138, 126, 135, 140, and 145 respectively. Complete the following code to find out how many new members the team can recruit this time? ( )

#include <iostream>
using namespace std;

int main() {
	int arr[10] = {125, 127, 136, 134, 137, 138, 126, 135, 140, 145};
	
	int count = 0;
	for(int i=0; i<10; i++)
		__________________________ // 在此处填入代码
	
	cout << count << endl;
	return 0;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

A. count = arr[i]>135? 1: 0;
B. count += arr[i]>135? 1: 0;
C. count++;
D. None of the above

Answer: B

Question 14

Which C++ statement below can correctly output They're planning a party for their friend's birthday.? ( )
A. cout << ‘They’re planning a party for their friend’s birthday." << endl;
B. cout << "They’re planning a party for their friend’s birthday.'<< endl;
C. cout << ‘They’re planning a party for their friend’s birthday.’<< endl;
D. cout << “They’re planning a party for their friend’s birthday.” << endl;

Answer: D

Question 15

If the output of the following C++ code is "gesp ccf org cn", which code should be filled in on the horizontal line? ( )

#include <iostream>
using namespace std;

int main() {
	string str = "gesp.ccf.org.cn";
	
	string delimiter = ".";
	string result="";
	string token;
	size_t found = str.find(delimiter);
	while (found != string::npos) {
		token = str.substr(0, found);
		result += token;
		result += " ";
		__________________________ // 在此处填入代码
		found = str.find(delimiter);
	}
	//最后一部分
	result += str;
		result += " ";
	cout << result << endl;
	return 0;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23

A. str = str.substr(found + delimiter.length(), str.length() - 1);
B. str = str.substr(found, str.length() );
C. str = str.substr(found, str.length() -1);
D. None of the above

Answer: A

2. True or False Questions (2 points each, 20 points in total)

Question 16

The GESP test is a level certification of the programming ability of the certifier. The same level of ability is basically unrelated to the programming language.

Answer: True

Question 17

The 16-bit complement of the integer -6 can be represented in hexadecimal as FFFA.

Answer: True

Question 18

The advantage of the complement code is that it can convert subtraction operations into addition operations, thereby simplifying the hardware design of the computer.

Answer: True

Question 19

The character constant '0' is often used to indicate the end of a string, which is the same as the character constant '0'.

Answer: False

Question 20

All elements of an array may not be stored contiguously in memory.

Answer: False

Question 21

In C++, you can assign values ​​to arrays and elements of each primitive type in an array.

Answer: False

Question 22

If it is a variable of int type and the value of the expression ((a | 3) == 3) is true, it means that it is between 0 and 3 (it may be 0 or 3).

Answer: True

Question 23

After executing the following C++ code, the output result is 8.

int a = 0b1010;
int b = 01100;
int c = a & b;
cout << c <<endl;
  • 1
  • 2
  • 3
  • 4

Answer: False

Question 24

After executing the following C++ code, the output result cannot be 89781. ( )

#include <iostream>
#include <cstdlib> // 为了使用 rand() 和 srand()
#include <ctime> // 为了使用 time()

using namespace std;

int main() {
	// 设置随机种子
	srand(time(NULL));
	
	int i = 1;
	int s[5];
	while(i <= 5)
	{
		int a = rand() % 10;
		if(a % 3 == (i + 1) % 3)
			s[i++] = a;
	}
	for(int i = 1; i <= 5; i++)
		cout << s[i];
	cout << endl;
	return 0;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23

Answer: True

Question 25

Cut the integer 3025 into two numbers, 30 and 25. Then square the sum of the two numbers and the result is equal to the original number. (30 + 25) × (30+ 25) = 55 × 55 = 3025. This number is called a "thunderstrike number". You can use enumeration to find all four-digit numbers that meet this condition. ( )

Answer: True

3. Programming questions (25 points each, 50 points in total)

Question 26

Question Name: Shift
time limit:1.0 s
Memory Limits:512.0 MB
Title Description
Xiao Yang learned the encryption technology shift, all uppercase letters are shifted backwards by a fixed number. The shift process treats the alphabet as a ring connected end to end. For example, when the shift is 3, the uppercase letter A will be replaced by D, and the uppercase letter Z will be replaced by C. Overall, the uppercase alphabet ABCDEFGHIJKLMNOPQRSTUVWXYZ will be replaced by DEFGHIJKLMNOPQRSTUVWXYZABC.
Note: When the offset is a multiple of 26, each uppercase letter will return to its original position after the offset, that is, the uppercase alphabet ABCDEFGHIJKLMNOPQRSTUVWXYZ will remain unchanged after the offset.
Input Format
The first line contains a positive integer n n n
Output Format
The output is at an offset of n n n In this case, the uppercase alphabet ABCDEFGHIJKLMNOPQRSTUVWXYZ is the result after shift replacement.
Example 1

3
  • 1
DEFGHIJKLMNOPQRSTUVWXYZABC
  • 1

Example explanation
When the offset is 3, the uppercase letter A will be replaced by D, and the uppercase letter Z will be replaced by C. Overall, the uppercase alphabet ABCDEFGHIJKLMNOPQRSTUVWXYZ will be replaced by DEFGHIJKLMNOPQRSTUVWXYZABC.
data range
For all data, it is guaranteed that 1 ≤ n ≤ 100 1≤n≤100 1n100

Reference Program

#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int fl=0;
	for(int i=0;i<26;i++){
		int j = (i+n)%26;
		char ch = 'A'+j;
		cout<<ch;
	}
	cout<<"n";
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

Question 27

Question Name: Find multiples
time limit:1.0 s
Memory Limits:512.0 MB
Title Description
Xiao Yang has a n n n A sequence of positive integers A = [ a 1 , a 2 , . . . , a n ] A=[a_1,a_2,...,a_n] A=[a1,a2,...,an]He wanted to know if there was i ( 1 ≤ i ≤ n ) i(1≤i≤n) i(1in) Make a i a_i ai Is a sequence A A A Multiples of all numbers in .
Input Format
The first line contains a positive integer t t t, represents the number of test case groups.
Next up t t t Group test cases.
For each test case, there are two lines. The first line contains a positive integer n n n; The second line contains n n n A positive integer representing a sequence A A A
Output Format
For each set of test cases, if there is i ( 1 ≤ i ≤ n ) i(1≤i≤n) i(1in) Satisfy for all k ( 1 ≤ k ≤ n ) a i k(1≤k≤n)a_i k(1kn)ai yes a k a_k ak If it is a multiple of , output Yes, otherwise output No.
Example 1

2
3
1 2 4
5
1 2 3 4 5
  • 1
  • 2
  • 3
  • 4
  • 5
Yes
No
  • 1
  • 2

Example explanation
For the first set of data, a 3 = 4 a_3=4 a3=4,satisfy a 3 a_3 a3 yes a 1 a_1 a1 and a 2 a_2 a2 multiples of.
data range
For all data, it is guaranteed that 1 ≤ t ≤ 10 , 1 ≤ n ≤ 1 0 5 , 1 ≤ a i ≤ 1 0 9 1≤t≤10,1≤n≤10^5,1≤a_i≤10^9 1t10,1n105,1ai109
Reference Program

#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+10;
int a[N];
int main(){
	int t;
	cin>>t;
	while(t--){
		int n;
		cin>>n;
		int x = 0;
		for(int i=1;i<=n;i++){
			cin>>a[i];
			x =max(x,a[i]);
		}
		int fl = 0;
		for(int i=1;i<=n;i++){
			if(x%a[i])fl=1;
		}
		if(fl)cout<<"Non";
		else cout<<"Yesn";
	}
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23