C language (enumeration, DEVFORGE learn programming community)

1, Inequality

 1 #include<stdio.h>
 2 #include<math.h>
 3 
 4 int main()
 5 {
 6     int a,b,n=1,n1;
 7     scanf("%d%d",&a,&b);
 8         
 9     double sum = 1, d = 1;
10     while(sum<=a || sum>=b)
11     {
12         n++;    
13         d += 1.0/n; //迭代除数d
14         sum += 1/ D;   // accumulated         
15      }        
 16      N1 = n-; // Reserved interval lower limit 
. 17      
18 is      the while (SUM> SUM && A < B)
 . 19      {    
 20 is          n-++ ;
 21 is          D = + 1.0 / n-; // iteration divisor D 
22 is          SUM = + . 1 / D;   // accumulation         
23 is      }
 24      N--; // upper limit value retention section 
25      
26 is      the printf ( " % D% D " , N1, n-);
 27      return  0;
28 }

2, and subsequence

 1 #include<stdio.h>
 2 #include<math.h>
 3 
 4 int main()
 5 {
 6     int n,m;
 7     scanf("%d%d",&n,&m);
 8     
 9     double sum = 0,t=0.000001,d;
10         
11     for(int i=n; i<=m; ++i)
12     {
13         d = (i/1000.0)*(i/1000.0); //防止数据陷进
14         sum += t/d;
15     }    
16     
17     printf("%.5f",sum);
18     
19     return 0;
20 }

3, the arrangement

 

Guess you like

Origin www.cnblogs.com/GoldenEllipsis/p/11544023.html