1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| #include<cstdio> int main() { int c,t,f; scanf("%d",&c); double sum = 0; for(int j = 0;j < c;++j) { sum = 0; f= 1; scanf("%d",&t); for(int i = 1;i<=t;++i) { sum += 1/double((i*f)); f *= -1; } printf("%.2f\n",sum); } }
|