东方博宜 1521. 计算分数加减表达式的值
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{double n ;cin >> n ;double sum ;sum = 0.0 ;double j ;j = 1.0 ;for (int i = 1 ; i <= n ; i++){sum += 1.0 / i * j ; j *= -1 ;}cout << fixed << setprecision(4) << sum ;return 0 ;
}