View Code of Problem 71

#include<stdio.h>
#include<math.h>
#include<string.h>
void main()
{
	float x=1,y=2,p;
	float sum=0,m;
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{	sum+=y/x;
		m=y;//设置一个中间变量来保存前一个分母;
		y=x+y;
		x=m;
	}
	printf("%.2f",sum);
}

Double click to view unformatted code.


Back to problem 71