阅读背景:

codeup_100000568_H

来源:互联网 

我的解答:

#include <stdio.h>
int main() {
	//如果想得到一个浮点数的结果,就要考虑让两个操作数至少有一个是浮点数,
	//强行乘一个1.0也是一个办法
	double a = 2, b = 3;
	double c = 1, d = 2;
	double x, y;                    //x是分子,y是分母 
	double ans = 3.5;               //ans初值为分母数列前两项和,即结果数列第二项 
	for(int i=3; i<=20; i++) {
		x = a + b;
		a = b;
		b = x;
		y = c + d;
		c = d;
		d = y;
		ans += x/y;
		//printf("x=%.6f y=%.6f ans=%.6f\n", x, y, ans);
	}
	printf("%.6f\n", ans);
	return 0;
}#include <stdio.h>
int main()



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: