关于数据类型
程序代码:
#include <stdio.h> int main(void) { int flag, i, n; int repeat, ri; double item, sum; scanf("%d", &repeat); for(ri = 1; ri <= repeat; ri++){ scanf("%d", &n); flag = 1; sum = 0; for (i = 1; i <=n; i++){ sum = sum +flag*i/(2*i-1); flag = -flag; } printf("sum = %.3f\n", sum); } }