#2531. 2023 CSP-J1 真题 · 阅读程序1

2023 CSP-J1 真题 · 阅读程序1

2023 CSP-J1 真题(120 分钟,总分 100 分)

阅读程序1(共 5 题,共 12.0 分)

1.

#include <iostream>
#include <cmath>
using namespace std;

double f(double a, double b, double c) {
    double s = (a + b + c) / 2;
    return sqrt(s * (s - a) * (s - b) * (s - c));
}

int main() {
    cout.flags(ios::fixed);
    cout.precision(4);

    int a, b, c;
    cin >> a >> b >> c;
    cout << f(a, b, c) << endl;
    return 0;
}

当输入为"2 2 2"时,输出为"1.7321"。

{{ select(1) }}

  • 正确
  • 错误

2. 将第7行中的"(s-b)(s-c)"改为"(s-c)(s-b)"不会影响程序运行的结果。

{{ select(2) }}

  • 正确
  • 错误

3. 程序总是输出四位小数。

{{ select(3) }}

  • 正确
  • 错误

4. 当输入为"3 4 5"时,输出为()。

{{ select(4) }}

  • "6.0000"
  • "12.0000"
  • "24.0000"
  • "30.0000"

5. 当输入为"5 12 13"时,输出为()。

{{ select(5) }}

  • "24.0000"
  • "30.0000"
  • "60.0000"
  • "120.0000"