这道题很简单,模拟就行了。 要注意: cotx=1tanx\cot x=\frac{1}{\tan x}cotx=tanx1。 C++复制#include <bits/stdc++.h> #define pi acos(-1) using namespace std; int main() { int t; cin >> t; while (t--) { double x; cin >> x; printf("%.6lf\n", x - 0.5 + 1.0 * atan(1.0 / tan(pi * x)) / pi); } }