首页 > 代码库 > 白书p35 习题2-4 子序列的和(subsequence)

白书p35 习题2-4 子序列的和(subsequence)

 1 #include<stdio.h>
 2 int main()
 3 {
 4     double n,m,sum=0;
 5     while(scanf("%lf%lf",&n,&m)!=EOF)
 6     {
 7         if(n==0&&m==0)
 8             break;
 9         for(;n<=m;n++)
10         {
11             sum+=1/(n*n);
12         }
13         printf("%.5f",sum);
14     }
15     return 0;
16 }

 

白书p35 习题2-4 子序列的和(subsequence)