5.在一个有序数组中,找>=某个数最左侧的位置(二分法)
int BSLeft(int arr[], int size, int target)
{
if (!arr) return;
int Left = 0;
int Right = size-1;
int Mid = 0;
int Index = -1;
while (Left < Right)
{
Mid = Left + ((Right-Left)>>1)
if (arr[Mid] >= target)
{
Index = Mid;
Right = Mid - 1;
}
else
{
Left = Mid + 1;
}
}
return Index;
}