c语言实践 1/1+1/2+1/3+1/4+...+1/n时间:2023-03-10 02:20:55 给定一个n求这个分式的和。 int n = 1; float sum = 0; float frac = 0; int i = 1; scanf_s("%d",&n); while (i <( n + 1)) //1到n { frac = 1.0 / i; sum = sum + frac; i++; } printf("sum is %f",sum);