程序分析:抓住分子与分母的变化规律:
分子a:1,2,3,5,8,13,21,34,55,89,144...
分母b:2,3,5,8,13,21,34,55,89,144,233...
分母b把数赋给了分子a,同时自己与分母的和(a+b)变成新分子赋给分母b。

代码:

#include<stdio.h>
int main()
{
int a = , b = , i, j, n;
float s = 0.0;
printf("请输入项数:\n");
scanf_s("%d", &n);
for (i = ; i <= n; i = i + )
{
s = s + 1.0 * a / b;
j = a;
a = b;
b = b + j;
}
printf("%f", s);
}
05-11 22:20