验证中...
gistfile1.txt
Raw Copy
#include <stdio.h>
float ji(int n)
{
float s=0;
int i;
for(i=1;i<=n;i=i+2)
s=s+1.0/i;
return s;
}
float ou(int n)
{
float s=0;
int i;
for(i=2;i<=n;i=i+2)
s=s+1.0/i;
return s;
}
int main()
{
int n;
float x;
scanf("%d",&n);
if(n%2==0)
x=ou(n);
else
x=ji(n);
printf("%f",x);
return 0;
}

Comment list( 0 )

You need to Sign in for post a comment

Help Search

Gitee_sixth 5th_float_left_close