#1322. GESP-C++三级(2023-12)

GESP-C++三级(2023-12)

CCF GESP C++ 三级 (2023 年 12 月)

一、单选题(每题 2 分,共 30 分)

第 1 题:下面 C++ 数组的定义中,会丢失数据的是 ( )。

{{ select(1) }}

  • char dict_key[] = {'p','t','o'};
  • int dict_value[] = {33,22,11};
  • char dict_name[]={'chen','wang','zhou'};
  • float dict_value[]={3,2,1};

第 2 题:在下列编码中,不能够和二进制 "1101 1101" 相等的是 ( )。

{{ select(2) }}

  • (221) 10 进制
  • (335) 8 进制
  • (dd) 16 进制
  • (5d) 16 进制

第 3 题:下面 C++ 代码执行后不能输出 "GESP" 的是 ( )。

{{ select(3) }}

  • string str("GESP"); cout<<str<<endl;
  • string str="GESP"; cout<<str<<endl;
  • string str("GESP"); cout<<str[1]<<str[2]<<str[3]<<str[4]<<endl;
  • string str{"GESP"}; cout<<str<<endl;

第 4 题:执行下面 C++ 代码输出是 ( )。

int temp=0;
for(int i =1;i<7;i++)
    for(int j=1;j<5;j++)
        if(i/j==2) 
            temp++;
cout<<temp<<endl;

{{ select(4) }}

  • 10
  • 8
  • 4
  • 3

第 5 题:执行下面 C++ 代码后,输出是 ( )。

string str("chen"); 
int x=str.length(); 
int temp=0; 
for(int i=0;i<=x;i++)
    temp++;
cout<<temp<<endl;

{{ select(5) }}

  • 4
  • 2
  • 5
  • 3

第 6 题:执行下面 C++ 代码后输出的是 ( )。

string str("chen"); 
int x=str.length();
cout<<x<<endl;

{{ select(6) }}

  • 4
  • 3
  • 2
  • 5

第 7 题:执行下面 C++ 代码后输出的是 ( )。

string str("chen");
cout<<str[5]<<endl;

{{ select(7) }}

  • 输出未知的数
  • 输出 'n'
  • 输出 '\0'
  • 输出空格

第 8 题:下面 C++ 代码执行后的输出是 ( )。

char ch[10]={'1'}; 
cout<<ch[2]<<endl;

{{ select(8) }}

  • 0
  • 1
  • 输出空格
  • 什么也不输出

第 9 题:下面 C++ 代码用于统计每种字符出现的次数,当输出为 3 时,横线上不能填入的代码是 ( )。

string str="ESP is a good programing test";
int x=0;
for(int i=0;i<str.length();i++){
    if(_)
        x++;
}
cout<<x<<endl;

{{ select(9) }}

  • str[i]=='o'
  • str[i]=='a'+14
  • str[i]==115
  • str[i]==111

第 10 题:32 位计算机中,C++ 的整型变量int能够表示的数据范围是 ( )。

{{ select(10) }}

  • 2^31~(2^31)-1
  • 2^32
  • -2^31~+(2^31)-1
  • -(2^31)+1~2^31

第 11 题:下面 C++ 程序执行的结果是 ( )。

int cnt=0; 
for(int i=0;i<=20;i++){
    if(i%3==0 && i%5==0)
        cnt++;
}
cout<<cnt;

{{ select(11) }}

  • 2
  • 3
  • 5
  • 4

第 12 题:C++ 的数据类型转换让人很难琢磨透,下列代码输出的值是 ( )。

int a=3;
int b=2;
cout<<a/b*1.0<<endl;

{{ select(12) }}

  • 1.5
  • 1
  • 2
  • 1.50

第 13 题:C++ 代码用于抽取字符串中的电话号码。约定:电话号码全部是数字,数字之间没有其他符号如连字符或空格等。代码中变量strSrc仅仅是示例,可以包含更多字符。下面有关代码说法,正确的说法是 ( )。

string strSrc="红十字:01084025890火警电话:119急救电话:120紧急求助:110";
string tel="";
for(int i=0;i<=strSrc.length();i++)
    if(strSrc[i]>='0'&&strSrc[i]<='9'){
        tel=tel+strSrc[i];
    } else if(tel!=""){
        cout<<tel<<endl;
        tel="";
    }

{{ select(13) }}

  • 代码将换行输出各个含有数字的电话号码。
  • 代码将不换行输出各个含有数字的电话号码,号码中间没有分隔。
  • 代码将不换行输出各个含有数字的电话号码,号码中间有分隔。
  • 不能够输出数字电话号码。

第 14 题:某公司新出了一款无人驾驶的小汽车,通过声控智能驾驶系统,乘客只要告诉汽车目的地,车子就能自动选择一条优化路线,告诉乘客后驶达那里。请问下面哪项不是驾驶系统完成选路所必须的 ( )。

{{ select(14) }}

  • 麦克风
  • 扬声器
  • 油量表
  • 传感器

第 15 题:现代计算机是指电子计算机,它所基于的是 ( ) 体系结构。

{{ select(15) }}

  • 艾伦・图灵
  • 冯・诺依曼
  • 阿塔纳索夫
  • 埃克特 - 莫克利

二、判断题(每题 2 分,共 20 分)

第 1 题:执行 C++ 代码cout<<(5&&2)<<endl;后将输出 1。( )

{{ select(16) }}

第 2 题:C++ 程序执行后,输入chen a dai输出应该为:chen。( )

string str;
cin>>str;
cout<<str;

{{ select(17) }}

第 3 题:执行 C++ 代码cout<<(5||2);后将输出 1。( )

{{ select(18) }}

第 4 题:执行下面 C++ 代码后将输出 "China"。( )

string a="china";
a.replace(0,1,"C");
cout<<a<<endl;

{{ select(19) }}

第 5 题:执行 C++ 代码将输出0 5,5 之后还有一个空格。( )

int list[10]={1,2,3,4,5,6,7,8,9,10}; 
for(int i=0;i<10;i++)
    if(i%5==0)
        cout<<list[i]<<" ";

{{ select(20) }}

第 6 题:下面 C++ 代码将输出 1。( )

int list[10]={1}; 
cout<<list<<endl;

{{ select(21) }}

第 7 题:下面 C++ 程序将输出 1。( )

int arr[10]={1}; 
cout<<arr[0]<<endl;

{{ select(22) }}

第 8 题:执行 C++ 代码,将输出1 3 5 7 9,9 之后还有一个空格。( )

int list[10]={1,2,3,4,5,6,7,8,9,10}; 
for(int i=0;i<10;i+=2)
    cout<<list[i]<<" ";

{{ select(23) }}

第 9 题:小杨最近在准备考 GESP,他用的 Dev C++ 来练习和运行程序,所以 Dev C++ 也是一个小型操作系统。( )

{{ select(24) }}

第 10 题:任何一个while循环都可以转化为等价的for循环。( )

{{ select(25) }}