【C】#牛牛学数列3#
牛牛学数列3
https://www.nowcoder.com/practice/f65c726d081c4160a9356eabf0dc21d9
#include <stdio.h> #include <math.h> int main() { int n; float ret = 0.0, tmp = 0.0; scanf("%d", &n); for(int i = 1; i <= n; i++){ tmp += pow(-1, i - 1) * (2 * i - 1); ret += 1.0 / tmp; } printf("%.3f", ret); return 0; }