题解 | #牛牛学数列3#
牛牛学数列3
https://www.nowcoder.com/practice/f65c726d081c4160a9356eabf0dc21d9
#include <stdio.h> int main() { int a,i,count=1; float sum=0; scanf("%d",&a); for(i=1;i<=a;i++) { sum+=1.0/(count*i); count*=-1; } printf("%.3f\n",sum); return 0; }