小杨父母带他到某培训机构给他报名参加 CCF 组织的 GESP 认证考试的第 级,那他可以选择的认证语言有( )种。
C: 3种(C++/Python/Scratch)
下面流程图在 yr 输入 时,可以判定 yr 代表闰年,并输出 2 月是 天,则图中菱形框中应该填入( )。
B: max<array[i] 找最大7
一般默认 位计算机系统中整型变量(int)还是 位,则整数能够表示的数据范围是( )。
A: arr[count++]=i。存7倍数到arr[0..4]
下列代码将十进制转化成八进制,则横线上应填入( )。
01#include <iostream> 02using namespace std; 03 04void decimal2octal(int decimal) { 05 int oct_number[100]; 06 int i = 0; 07 while (decimal > 0) { 08 ____________ 09 //在此处填入代码 10 } 11 for (int j = i - 1; j >= 0; j--) { 12 cout << oct_number[j]; 13 } 14 cout << endl; 15}
C: 209。x+='0'+'6'+'2'+'9'=48+54+50+57=209
二进制数 对应的十进制数是( )。
B: count+=arr[i]>135?1:0。条件累加
下列流程图的输出结果是( )。
D: 双引号包,内单引号不需转义,末尾有."
下列代码的输出结果是( )。
01#include <iostream> 02using namespace std; 03int main() { 04 int a = 12; 05 int result = a >> 2; 06 cout << result << endl; 07 return 0; 08}
A: str=str.substr(found+1, len-found-1)。移过.继续找
下列代码的输出结果是( )。
01#include <iostream> 02using namespace std; 03 04int main() { 05 int a = 5; 06 int b = 10; 07 a = a ^ b; 08 b = a ^ b; 09 a = a ^ b; 10 11 cout << "a = " << a << ", b = " << b << endl; 12 return 0; 13}
(跳,需完整选项)
如果字符串定义为 char str[] = "GESP";,则字符数组 str 的长度为( )。
(跳,需完整选项)
在下列代码的横线处填写( ),可以使得输出是"7"。
01#include <iostream> 02using namespace std; 03 04int main() { 05 int array[5] = {3, 7, 5, 2, 4}; 06 int max = 0; 07 for(int i=0; i<5; i++) 08 if(____________) // 在此处填入代码 09 max = array[i]; 10 cout << max << endl; 11 return 0; 12}
B: max<array[i] 找最大7
小杨在做数学题,题目要求找出从 到 中能被 整除的数字,即 ,则横线处应填入哪个代码?( )
01#include <iostream> 02using namespace std; 03int main() { 04 int arr[35]; 05 int count = 0; 06 for (int i = 1; i <= 35; i++) { 07 if (i % 7 == 0) 08 ____________ 09 // 在此处填入代码 10 } 11 12 for (int i = 0; i < count; i++) 13 cout << arr[i] << endl; 14 return 0; 15}
D: 以上均不对。count++无条件,身高135也计入
已知字符 '0' 的 ASCII 编码的十进制表示为 ,则执行下面 C++ 代码后,输出是( )。
01#include <iostream> 02using namespace std; 03int main() { 04 string s = "0629"; 05 int n = s.length(); 06 int x = 0; 07 for(int i = 0; i < n; i++) 08 x += s[i]; 09 cout << x << endl; 10 return 0; 11}
C: 209。x+='0'+'6'+'2'+'9'=48+54+50+57=209
某小学男子篮球队招募新成员,要求加入球队的成员身高在 厘米以上(不含 厘米)。本次报名的人员有 人,他们的身高分别是 、、、、、、、、、。完善以下代码,求出本次球队能够招募到新成员的人数?( )
01#include <iostream> 02using namespace std; 03int main() { 04 int arr[10] = {125, 127, 136, 134, 137, 138, 126, 135, 140, 145}; 05 int count = 0; 06 for(int i=0; i<10; i++) 07 ____________ 08 // 在此处填入代码 09 10 cout << count << endl; 11 return 0; 12}
B: count+=arr[i]>135?1:0。身高>135条件累加
下面可以正确输出 They're planning a party for their friend's birthday. 的 C++ 语句是?( )
D: 双引号包内单引号不转义,末尾句点在外"
如果执行下面 C++ 代码后,输出的结果是"gesp ccf org cn",则横线上应填入哪个代码?( )
01#include <iostream> 02using namespace std; 03int main() { 04 string str = "gesp.ccf.org.cn"; 05 string delimiter = "."; 06 string result=""; 07 08 string token; 09 size_t found = str.find(delimiter); 10 while (found != string::npos) { 11 token = str.substr(0, found); 12 result += token; 13 result += " "; 14 ____________ // 在此处填入代码 15 found = str.find(delimiter); 16 } 17 18 result += str; 19 result += " "; 20 21 //最后一部分 22 23 cout << result << endl; 24 return 0; 25}
A: str=substr(found+1, len-found-1)。移过.继续找
GESP 测试是对认证者的编程能力进行等级认证,同一级别的能力基本上与编程语言无关。
正确。GESP认证计算思维不限定语言
整数 -6 的 位补码可用十六进制表示为 FFFA。
正确。-6 16位补码=FFFA
补码的优点是可以将减法运算转化为加法运算,从而简化计算机的硬件设计。
正确。补码转减法为加法,简化硬件设计
字符常量 '\0' 常用来表示字符串结束,和字符常量 '0' 相同。
错。\0是空字符(0),0是数字0(48),不同
数组的所有元素在内存中可以不连续存放。
错。数组元素在内存连续存放
C++ 中可以对数组和数组的每个基础类型的元素赋值。
正确。数组和元素都可赋值
如果 a 为 int 类型的变量,且表达式 ((a | 3) == 3) 的值为 true,则说明 a 在从 到 之间(可能为 、可能为 )。
错。a|3==3,a=0..3但a=7时7|3=7≠3,不在0..3→错. 实际a=0,1,2,3时成立,7,15等不
执行下面 C++ 代码后,输出的结果是 。
01int a = 0b1010; 02int b = 01100; 03int c = a & b; 04cout << c <<endl;
错。a=0b1010=10,b=01100(八进制)=576,c=10&576=0不是8
执行下面 C++ 代码后,输出的结果不可能是 。
01#include <iostream> 02#include <cstdlib> // 为了使用 rand() 和 srand() 03#include <ctime> // 为了使用 time() 04 05using namespace std; 06 07int main() { 08 // 设置随机种子 09 srand(time(NULL)); 10 11 int i = 1; 12 int s[5]; 13 while(i <= 5) { 14 int a = rand() % 10; 15 if(a % 3 == (i + 1) % 3) 16 s[i++] = a; 17 } 18 for(int i = 1; i <= 5; i++) 19 cout << s[i]; 20 cout << endl; 21 return 0; 22}
错。rand()随机,任何序列都可能(虽然89781极特定)
把整数 从中剪开分为 和 两个数,此时再将这两数之和平方,计算结果又等于原数。,这样的数叫"雷劈数"。可以使用枚举的方法求出所有符合这样条件的四位数。
枚举所有情况,注意剪枝;+ - * / %,整数/整数得整数(入门)