1 double l=左边界,r=右边界,l_mid,r_mid,flag=1e-9; 2 while(r-l>flag) 3 { 4 l_mid=l+(r-l)/3.0; 5 r_mid=r-(r-l)/3.0; 6 if(count(l_mid)>count(r_mid)) l=l_mid; 7 else r=r_mid; 8 } 9 printf("%f",count(l)) ; 10 //count是计算值的函数