C语言分数之和

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/DuckyLoser/article/details/79595322
#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<windows.h>

double main()
{
	double a = 2;
	double b = 1;
	double sum = 0;
	double i = 0;
	double tmp = 0;
	for (i = 1; i <= 20; i++)
	{
		sum += a / b;
		tmp = a;
		a += b;
		b = tmp;
	}
	printf("%lf", sum);
	system("pause");
	return 0;
}

阅读更多
换一批

没有更多推荐了,返回首页