#include<stdio.h>
int main()
{
int i = 1;
double a = 2.0, b=1.0;
double sum = 0.0, c = 0.0;
while( i<= 20 )
{
c = a/b; //每次进循环后先构造新分式
sum = sum + c;
a = a+b;
b = a-b; //变换a,b的值
i++;
}
printf( "sum = %f\n",sum);
return 0;
分数序列求和
最新推荐文章于 2024-08-18 09:30:00 发布