/////////////////////////////////////////
// C-Free 4.1
// MinGW 3.4.5
// veket的小号
/////////////////////////////////////////
#include
double f(int);
int main()
{
printf("%lf", f(100));
return 0;
}
double f(int n)
{
double sum;
int i;
for(sum=0,i=0;i
sum += 1.0/(2*i+1);
}
return sum;
}
#include
void main()
{
int n;
printf("输入你要计算的数目:");
scanf("%d",&n);
printf("sum=%f",sumx(n));
}
double sumx(int n)
{
int i;
double s=0.0;
for (i=1;i<=n;i++)
s+=(1.0/(2*i-1));
return s;
}
#include
double fun( int );
viod main()
{ printf("%f",fun(100);
}
double fun(int a)
{ int i;
double sum=0;
for(i=1;i sum=sum+(double)1/i;
return sum;
}
#include
double fun(int);
main()
{
int n;
printf("输入n:\n");
scanf("%d",&n);
printf("前%d项和为%lf\n",n,fun(n));
}
double fun(int n)
{
double sum=0;
int i;
for(i=1;i<=n;i++)
{
sum+=(double)1/(2*i-1);
}
return sum;
}
#include
void main()
{
double i=1,j=100;
double sum=0;
while(--j)
{
sum=sum+i;
i=i+2;
i=1/i;
}
printf("%lf\n",sum);
}