找到 375 道单选题
EXY-SC-0175
第 201 题

对如下 4 个扑克牌进行排序,

struct Card {
    int value;
    char suit; // 花色
};
 
Card cards[4] = {{5,'A'}, {3,'B'}, {5,'C'}, {3,'D'}};

使用某排序算法按value排序后,结果为:{3,'D'}, {3,'B'}, {5,'A'}, {5,'C'},则这个排序算法是稳定的吗?

A

稳定,因为相同 value 的元素相对顺序保持不变

B

不稳定,因为 {3,'D'} 出现在 {3,'B'} 之前

C

无法判断

D

稳定,因为结果是有序的

语言: C++
GESP真题 四级
2025.12
单选题号: 10
EXY-SC-0174
第 202 题

给定函数 climbStairs(int n) 的定义如下,则 climbStairs(5) 的返回的值是( )。

int climbStairs(int n) {
    if(n <= 2) return n;
    int a = 1, b = 2;
    for(int i = 3; i <= n; i++) {
        int temp = a + b;
        a = b;
        b = temp;
    }
    return b;
}
A

5

B

8

C

13

D

10

语言: C++
GESP真题 四级
2025.12
单选题号: 9
EXY-SC-0173
第 203 题

运行如下代码会输出( )。

struct Point {
    int x, y;
};
 
struct Rectangle {
    Point topLeft;
    Point bottomRight;
};
 
int main() {
    Rectangle rect = {{10, 10}, {20, 20}};
    rect.topLeft.x = 5;
    Point* p = &rect.bottomRight;
    p->y = 5;
    cout << rect.topLeft.x + rect.bottomRight.y;
    return 0;
}
A

10

B

30

C

15

D

20

语言: C++
GESP真题 四级
2025.12
单选题号: 8
EXY-SC-0172
第 204 题

执行完下面的代码后,abc 的值分别是( )。

void byValue(int x) { x = 100; }
void byRef(int& x) { x = 200; }
void byPointer(int* x) { *x = 300; }
 
int main() {
    int a = 1, b = 2, c = 3;
    byValue(a);
    byRef(b);
    byPointer(&c);
    return 0;
}
A

100 200 300

B

1 2 3

C

1 200 300

D

1 2 300

语言: C++
GESP真题 四级
2025.12
单选题号: 7
EXY-SC-0171
第 205 题

执行完下面的代码后,输出是( )。

int a = 1;
 
void test() {
    int a = 2;
    {
        int a = 3;
        a++;
    }
    a++;
    cout << a << " ";
}
 
int main() {
    test();
    cout << a;
    return 0;
}
A

3 1

B

4 1

C

3 2

D

4 2

语言: C++
GESP真题 四级
2025.12
单选题号: 6
当前页显示 201 - 205 ,共 375 道单选题