标签:NPU scanf amp inpu ble int oid print number
#include<stdio.h>
double fun(int n)
{
int i=2,j=1,count=0,t;
double sum=0.0;
while(count<n)
{
sum=sum+(double)i/j;
t=i;
i=i+j;
j=t;
count++;
}
return sum;
}
void main()
{
int n;
printf("please input a number:");
scanf("%d",&n);
printf("前n项之和为%f\n",fun(n));
}
求出如下分数列的前n项之和 2/1+3/2+5/3+8/5+13/8+21/13.....
标签:NPU scanf amp inpu ble int oid print number
原文地址:https://www.cnblogs.com/-slz-2/p/11254234.html