#1485. GESP四级真题(202403)

GESP四级真题(202403)

C++ 四级 2024 年 03 月

1 单选题(每题 2 分,共 30 分)

第 1 题 若函数声明为 int f(int &x){ x+=3; return x; } ,则对声明的变量 int a=3 ,下面哪个调用能够改变 a 的值( )。 {{ select(1) }}

  • f(&a);
  • f(*a);
  • f(a);
  • f(a-3);

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

int main()
{
    int x[]={2, 0, 2, 4};
    char geSP[]="Grade Examination of SP";

    cout << geSP[sizeof(x)] << endl;

    cout << endl;
    return 0;
}

{{ select(2) }}

  • G
  • e
  • n
  • P

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

int foo(float *f)
{
    return int(*f*2);
}

int main()
{
    float fnum[10]={1.1};
    fnum[1]=foo(fnum);
    cout << fnum[0]+fnum[1] << endl;

    cout << endl;
    return 0;
}

{{ select(3) }}

  • 1
  • 1.1
  • 3
  • 3.1

第 4 题 对二维数组 int arr[3][16]; ,则 arr[1] 占用内存的大小为( )字节。 {{ select(4) }}

  • 4
  • 16
  • 48
  • 64

第 5 题 对二维数组 int arr[3][16]; ,若 arr 的地址是 0x28cbc0 ,则 arr[1] 的值是( )。 {{ select(5) }}

  • 0x28cbc4
  • 0x28cbd0
  • 0x28cc00
  • 不确定

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

int main()
{
    char *p="I love GESP!";
    cout << p+5 << endl;

    cout << endl;
    return 0;
}

{{ select(6) }}

  • e
  • I lov
  • e GESP!
  • GESP!

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

int rc=5;
int main()
{
    int rc;
    cout << ++rc << endl;

    cout << endl;
    return 0;
}

{{ select(7) }}

  • 0
  • 1
  • 6
  • 不确定

第 8 题 下面C++函数中采用的算法是( )。

int fib(int n)
{
    int i, f[n]={0, 1};

    for(int i=2; i<=n; i++)
        f[i]=f[i-1]+f[i-2];

    return f[n];
}

{{ select(8) }}

  • 递推
  • 递归
  • 迭代
  • 循环

第 9 题 插入排序在最好情况下的时间复杂度是( )。 {{ select(9) }}

  • O(1)O(1)
  • O(N/2)O(N/2)
  • O(N)O(N)
  • O(N2)O(N^2)

第 10 题 在如下的C++代码执行后,设第11和12行的输出地址值分别为 X 和 Y ,则下面正确的是( )。

struct pass{
    int no;
    char name[20];
    int level;
};

int main()
{
    struct pass XiaoYang;

    cout << "&XiaoYang=" << &XiaoYang << endl; //第11行
    cout << "&(XiaoYang.no)=" << &(XiaoYang.no) << endl; //第12行

    cout << endl;
    return 0;
}

{{ select(10) }}

  • X>Y
  • X==Y
  • X<Y
  • 不确定

第 11 题 如果文件 1.txt 中的内容如下,则执行下面C++代码时,注释了 #### 那行代码所输出的 x 的值为( )。

50 2024 3.16 I
love
GESP!
int main()
{
    ifstream fin;
    string line;
    int x;
    fin.open("1.txt",ios::in);

    for (int i=0; i< 2; i++){
        fin >> line;
        cout << line << endl;
    }
    fin>>x;
    cout << x << endl; //####

    cout << endl;
    return 0;
}

{{ select(11) }}

  • 5
  • 2024
  • 3
  • 0

第 12 题 执行下列C++代码时输出中的第2行是( )。

int main()
{
    char *s[]={(char*)"2024",(char*)"3.16",(char*)"GESP"};

    for (int i=0; i< 2; i++){
        cout << *s+i << endl;
    }

    cout << endl;
    return 0;
}

{{ select(12) }}

  • 2024
  • 3.16
  • 024
  • 3

第 13 题 C++语言中下面哪个关键字能够限定对象的作用域( )。 {{ select(13) }}

  • extern
  • static
  • inline
  • public

第 14 题 小杨的父母最近刚刚给他买了一块华为手表,他说手表上跑的是鸿蒙,这个鸿蒙是( )。 {{ select(14) }}

  • 小程序
  • 计时器
  • 操作系统
  • 神话人物

第 15 题 中国计算机学会(CCF)在2024年1月27日的颁奖典礼上颁布了王选奖,王选先生的重大贡献是( )。 {{ select(15) }}

  • 制造自动驾驶汽车
  • 创立培训学校
  • 发明汉字激光照排系统
  • 成立方正公司

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

第 1 题 对 int a[]={2,0,2,4,3,1,6} ,执行第一趟选择排序处理后 a 中数据变为 {0,2,2,4,3,1,6} 。( ) {{ select(16) }}

第 2 题 如果待排序数据不能都装进内存,需要使用外排序算法。( ) {{ select(17) }}

第 3 题 定义变量 int a=5 , 则 cout << &++a 会输出 6 。( ) {{ select(18) }}

第 4 题 两个函数之间可以使用全局变量来传递数据。 ( ) {{ select(19) }}

第 5 题 定义数组 int a[2024][3][16]={2,0,2,4,3,1,6} ,则 cout << a[2023][2][15] 的结果不确定。( ) {{ select(20) }}

第 6 题 在C++语言中,函数的参数为指针时,可以在函数内部修改该参数的值。( ) {{ select(21) }}

第 7 题 在C++语言中 try 子句里抛出的结构体等类型的异常无法被 catch 捕获。( ) {{ select(22) }}

第 8 题 C++语言中 cout << 9^2 << endl; 会输出81。( ) {{ select(23) }}

第 9 题 小杨今年春节回奶奶家了,奶奶家的数字电视要设置ip地址并接入到WIFI盒子才能收看节目,那这个WIFI盒子具有路由器的功能。( ) {{ select(24) }}

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