1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #include <iostream> #include <cmath> using namespace std; const double r = acos(0.5); int a1, b1, c1, d1; int a2, b2, c2, d2; inline int sq(const int x) { return x * x; } //inline的作用是减少函数的开销 inline int cu(const int x) { return x * x * x; } int main() { cout.flags(ios::fixed); cout.precision(4); cin >> a1 >> b1 >> c1 >> d1; cin >> a2 >> b2 >> c2 >> d2; int t = sq(a1 - a2) + sq(b1 - b2) + sq(c1 - c2); if (t <= sq(d2 - d1)) cout << cu(min(d1, d2)) * r * 4; else if (t >= sq(d2 + d1)) cout << 0; else { double x = d1 - (sq(d1) - sq(d2) + t) /sqrt(t)/2; double y = d2 - (sq(d2) - sq(d1) + t) / sqrt(t)/2; cout << (x * x * (3 * d1 - x) + y * y * (3 * d2 - y)) * r; } cout << endl; return 0; } |
假设输入的所有数的绝对值都不超过1000,完成下面的判断题和单选题:
0 of 6 Questions completed
Questions:
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You must first complete the following:
0 of 6 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
将第 21行中 t的类型声明从int
改为double
,不会影响程序运行的结果。( )
将第 24、25 行中的/ sqrt(t) / 2
替换为/ 2 / sqrt(t)
,不会影响程序运行的结果。( )
将第 26 行中的x * x
改成sq(x)
,y * y
改成sq(y)
,不会影响程序运行的结果。( )
当输入为0 0 0 1 1 0 0 1
时,输出为1.3090
。
当输入为1 1 1 1 1 1 1 2
时,输出为( )。
这段代码的含义为( )。