1/2+2/3+3/5+.....前十项和
2015-04-29 02:16:41 -0400
#include<stdio.h>
void main()
{
float sum,t;
float p,q,f;
int i=1;
sum=0;
p=1;
q=2;
t=p/q;
while(i<=10)
{
sum+=t;
i++;
f=p;
p=q;
q=f+q;
t=p/q;
}
printf("1/2+2/3+3/5+.....前十项和=%f\n",sum);
}
Back to home
Subscribe |
Register |
Login
| N