二分法(整數型別)的基本框架

splub發表於2020-01-17
void binary_search(int left, int right){
     int mid;
     while(left < right){
          mid = (left+right) >> 1;
          if(checkout(mid)){                //答案在mid右邊
               left = mid+1;
          }  else  {
               right = mid;
          }
     }
}

相關文章