1 回答
new_stein
TA贡献3条经验 获得超1个赞
试试这个
#include <stdio.h> int main() { // init var float i_deno = 1, i_mole = 2; // loop var int i = 0, i_loopCtl = 1; // result var float f_sum = 0; printf("How many items to calculate?\n"); scanf("%d", &i_loopCtl); printf("The sum of the first %d terms will be calculated\n", i_loopCtl); for (; i < i_loopCtl; i++) { f_sum += i_mole/i_deno; int i_tmp = i_mole; i_mole += i_deno; i_deno = i_tmp; } printf("The sum is : %f\n", f_sum); return 0; }
- 1 回答
- 0 关注
- 1006 浏览
添加回答
举报
0/150
提交
取消