443 #32. 计算分数加减表达式的值 Accepted 100 16 ms 340 K C++ / 291 B pengjinchen 2024-10-11 20:42:33 显示原始代码 #include #include using namespace std; int main() { int n; double s = 0; cin >> n; for (int i = 1; i <= n; i++) { if (i % 2 == 1) { s += 1.0 / i; } else { s -= 1.0 / i; } } printf("%.4lf", s);
return 0;
}