#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
float y = 0;
int i;
for(i = 0, i < n; ++i)
{
y += 1.0 / (2 * i + 1);
}
printf("y=%f\n", y);
return 0;
}
int main()
{
int n;
double total=0.0f;
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
total += (float)1/(2*i-1);
}
printf("total = %lf\r\n",total);
}
forlinx@ubuntu:/mnt/hgfs/share/6ulx-s2/3_test/strcpy.c$ ./main
3
total = 1.533333
forlinx@ubuntu:/mnt/hgfs/share/6ulx-s2/3_test/strcpy.c$ ./main
7
total = 1.955134
forlinx@ubuntu:/mnt/hgfs/share/6ulx-s2/3_test/strcpy.c$ ./main
11
total = 2.180875
个人觉得,最好的方法就是好好上课,掌握基础技能,然后找到适合自己的方法。没有好的方法,就多做题吧。