5.02
NguyenAnhQuan
c_cpp
a year ago
628 B
11
Indexable
Never
#include <iostream> #include <iomanip> using namespace std; double pre[20]; double pow(double n, double k) { double res = 1; for (int i = 1; i <= k; i++) res *= n; return res; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); double x; cin >> x; double sum = x; for (int i = 1; i <= 30; i++) { double t = pow(-1, i)*pow(x, 2*i+1); for (double j = 1; j <= 2*i+1; j++) t /= j; sum += t; } cout << setprecision(4) << fixed << sum; return 0; }