二分查找算法
static int BinarySearch(int[] arr, int dest)
{
int rs = -1;
int low = 0;
int hight = arr.Length - 1;
while (low <= hight)
{
int mid = (low + hight) / 2;
if (dest == arr[mid])
{
rs = arr[mid];
break;
}
else if (dest < arr[mid])
{
hight = mid - 1;
}
else if (dest > arr[mid])
{
low = mid + 1;
}
}
return rs;
}