#cspjc2023y1. 2023csp-j初赛程序阅读1

2023csp-j初赛程序阅读1

2023csp-j初赛程序阅读1

判断题 1.5 分,选择题 3 分

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));  //7行
}

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;
}

​ 假设输入的所有数都为不超过1000的正整数,完成下面的判断题和单选题:

判断题

1.(2分)当输入为“2 2 2”时,输出为“1.7321”( )。 {{ select(1) }}

  • √
  • ×

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

  • √
  • ×

3.(2分)程序总是输出四位小数( ) {{ 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”