1
0
mirror of https://github.com/renbaoshuo/202401-programming-assignments.git synced 2024-11-23 15:48:42 +00:00
202401-programming-assignments/【实践课外】4.循环结构1/7-8 循环-奇数分之一序列前N项和.c

17 lines
207 B
C

#include <stdio.h>
int main() {
int n;
double ans = 0;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
ans += 1.0 / (i * 2 + 1);
}
printf("%.2lf\n", ans);
return 0;
}