#1482. GESP三级真题(202403)
GESP三级真题(202403)
C++ 三级 2024 年 03 月
1 单选题(每题 2 分,共 30 分)
第 1 题 整数-5的16位补码表示是( )。 {{ select(1) }}
- 1005
- 1006
- FFFA
- FFFB
第 2 题 如果16位短整数 -2 的二进制是"FFFE",则短整数 -4
的十六进制是( )。
{{ select(2) }}
- FF04
- FFFA
- FFFC
- FFFH
第 3 题 下面C++代码执行后的输出是( )。
int main()
{
cout << (3|16) << endl;
cout << endl;
return 0;
}
{{ select(3) }}
- 3
- 16
- 19
- 48
第 4 题 定义整数 int x=-5
,则执行C++代码 cout << (x == (x<<1>>1))
输出是( )。
{{ select(4) }}
- 0
- 1
- -5
- 5
第 5 题 已知字符 '0' 的ASCII编码的十进制表示为48,则执行下面C++代码后,输出是( )。
int main()
{
string s="316";
int n=s.length();
int x=0;
for(int i = 0; i < n; i++)
x += s[i];
cout << x << endl;
cout << endl;
return 0;
}
{{ select(5) }}
- 10
- 58
- 154
- 316
第 6 题 下面C++代码执行后数组中大于0的数的特征是( )。
int main()
{
int a[20],i;
for(i = 0; i < 20; i++)
a[i] = i+1;
for(int i = 0; i < 20; i++)
if((a[i]%2)&&(a[i]%3))
a[i] = 0;
for(i = 0; i < 20; i++)
if(a[i])
cout << a[i] << " ";
cout << endl;
return 0;
}
{{ select(6) }}
- 2的倍数
- 3的倍数
- 能被2或3整除的数
- 能被2和3同时整除的数
第 7 题 执行下面C++代码后输出的第一个数是( )。
int main()
{
int a[20],i;
for(i = 0; i < 20; i++)
a[i] = i+1;
for( ; i > 0; i--)
cout << a[i-1] << " ";
cout << endl;
return 0;
}
{{ select(7) }}
- 20
- 19
- 1
- 不确定
第 8 题 在下列代码的横线处填写( ),可以使得输出是 GESP IS INTERESTING 。
int main()
{
string str="gEsP is Interesting";
int x = str.length();
for(int i = 0; i < x; i++)
if ((str[i]>='a') && (str[i]<='z'))
________________________;
cout << str << endl;
cout << endl;
return 0;
}
{{ select(8) }}
str[i]+='a'-'A'
str[i]+=20
str[i]+='A'-'a'
- 无法实现
第 9 题 假设英文句子由若干词构成。下面C++代码统计输出的词数是( )。
int main()
{
string str="gEsP is Interesting !";
int x = str.length();
int nwords = 0;
for(int i = 0; i < x; i++)
if (str[i]==' '){
nwords++;
while(str[++i]==' ') ;
}
cout << nwords << endl;
cout << endl;
return 0;
}
{{ select(9) }}
- 1
- 2
- 3
- 4
第 10 题 C++的字符变量的码值是整数,下面字面量形式的字符码值最大的是( )。 {{ select(10) }}
- 100
- 075
- 0x70
- 0x60
第 11 题 下面C++程序执行的结果是( )。
int main()
{
int a[20],i;
int cnt=0;
for(i = 0; i < 20; i++)
a[i] = i+1;
for( ; i > 1; i--)
if((a[i-1]+a[i-2])%3)
cnt++;
cout << cnt << endl;
cout << endl;
return 0;
}
{{ select(11) }}
- 5
- 6
- 10
- 12
第 12 题 定义字符数组 char str[20] = {'G', 'E', 'S', 'P'};
,则 str
的字符串长度为( )。
{{ select(12) }}
- 4
- 5
- 19
- 20
第 13 题 定义整型变量 int a=3, b=16
,则 a|b
的值和 a+b
的关系是( )。
{{ select(13) }}
- 大于
- 等于
- 小于
- 等于或小于
第 14 题 小杨的父母最近刚刚给他买了一块华为手表,他说手表上跑的是鸿蒙,这个鸿蒙是( )。 {{ select(14) }}
- 小程序
- 计时器
- 操作系统
- 神话人物
第 15 题 中国计算机学会(CCF)在2024年1月27日的颁奖典礼上颁布了王选奖,王选先生的重大贡献是( )。 {{ select(15) }}
- 制造自动驾驶汽车
- 创立培训学校
- 发明汉字激光照排系统
- 成立方正公司
2 判断题(每题 2 分,共 20 分)
第 1 题 任意整数 a
的二进制反码与补码都有1位不同。 ( )
{{ select(16) }}
- 对
- 错
第 2 题 对整型变量 int a = 3
,执行C++代码 a<<2
将把2输出到 a
中。( )
{{ select(17) }}
- 对
- 错
第 3 题 下面C++代码可以计算1到100的累加和,采用的是穷举法。( )
int main()
{
int i,sum=0;
for(int i = 1; i <= 100 ; i++)
sum += i;
cout << sum << endl;
cout << endl;
return 0;
}
{{ select(18) }}
- 对
- 错
第 4 题 一个 int 类型变量 a
,执行操作 (a<<2>>2)
后的值一定是 a
。( )
{{ select(19) }}
- 对
- 错
第 5 题 在C++语言中, (010<<1)
执行结果是 100
。( )
{{ select(20) }}
- 对
- 错
第 6 题 执行下面C++代码后将输出 2
。( )
int main()
{
string str="gEsP is Interesting";
int x = str.find("s");
cout << x << endl;
cout << endl;
return 0;
}
{{ select(21) }}
- 对
- 错
第 7 题 在C++语言中,字符数组被定义时,它的大小可以调整。( ) {{ select(22) }}
- 对
- 错
第 8 题 对定义的数组 int a[7]={2,0,2,4,3,1,6}
,可以用简单循环就找到其中最小的整数。( )
{{ select(23) }}
- 对
- 错
第 9 题 小杨今年春节回奶奶家了,奶奶家的数字电视要设置ip地址并接入到WIFI盒子才能收看节目,那这个WIFI盒 子具有路由器的功能。( ) {{ select(24) }}
- 对
- 错
第 10 题 任何一个 for
循环都可以转化为等价的 while
循环( )。
{{ select(25) }}
- 对
- 错