A. [GESP]L4-202503-Q3009-S

    客观题

[GESP]L4-202503-Q3009-S

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

关于下述代码,说法错误的是( )。

int multiply(int x, int y);

int main() {
    int a = 4;
    int b = 5;
    int result = multiply(a, b);
    std::cout << "The result is: " << result << std::endl;
    return 0;
}

int multiply(int x, int y) {
    return x * y;
}

{{ select(1) }}

  • 函数 multiply 的定义应该放到函数 main 之前。
  • 函数声明 int multiply(int x, int y); 中明确指定了函数 multiply() 的返回值为整数类型。
  • 在 main 函数中,函数 multiply 通过 multiply(a, b) 被调用,其中 a 和 b 是定义在 main 函数中的变量,它们作为实参传递给了 multiply 函数的形参 x 和 y。
  • 运行上述代码,将输出 The result is: 20。

GESP 2025.03 C++ 四级 全真模拟赛

未参加
状态
已结束
规则
OI
题目
27
开始于
2026-11-20 13:31
结束于
2026-11-25 13:31
持续时间
2 小时
主持人
参赛人数
0