double bsearch_f(double q[], int size, double target)

{

   const double eps = 1e-6;   // eps 表示精度,取决于题目对精度的要求

   int l = 0, r = size - 1;

   while (r - l > eps)  // 两种写法:此时是用精度控制循环次数,直接控制循环100次也是OK的!

   {

       int mid = (l + r) / 2;

       if (q[mid] >= target) r = mid;

       else l = mid + 1;

   }

   if(q[l] != target) return -1;

   return l;

}

double bsearch_f(double q[], int size, double target)
{
    const double eps = 1e-6;   // eps 表示精度,取决于题目对精度的要求
    int l = 0, r = size - 1;
    while (r - l > eps)  // 两种写法:此时是用精度控制循环次数,直接控制循环100次也是OK的!
    {
        int mid = (l + r) / 2;
        if (q[mid] >= target) r = mid;
        else l = mid + 1;
    }
    if(q[l] != target) return -1;
    return l;
}