题目编号
语言
全部语言
等级
全部等级
考查知识点
选择考查知识点 (0)
找到 1506 道单选题
EXY-SC-0176
第 1331 题

下面的函数 selectTopK() 实现从 n 个学生中选出前 k 名成绩最好的学生颁发奖学金(不需要对所有学生完全排序,只需要找出前 k 名),则横线上应填写( )。

struct Student {
    string name;
    int score;
};
 
void selectTopK(Student students[], int n, int k) {
    for (int i = 0; i < k; i++) {
        int maxIdx = i;
        for (__________________) {  // 在此处填入代码
            if (students[j].score > students[maxIdx].score) {
                maxIdx = j;
            }
        }
 
        if (maxIdx != i) {
            Student temp = students[i];
            students[i] = students[maxIdx];
            students[maxIdx] = temp;
        }
    }
}
A

int j = 0; j < n; j++

B

int j = i + 1; j < n; j++

C

int j = i; j < n; j++

D

int j = 1; j <= n; j++

语言: C++
GESP真题 四级
2025.12
单选题号: 11
EXY-SC-0175
第 1332 题

对如下 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
第 1333 题

给定函数 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
第 1334 题

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

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
第 1335 题

执行完下面的代码后,a、b 和 c 的值分别是( )。

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
当前页显示 1331 - 1335 ,共 1506 道单选题