#region 二分查找法 public static int BinarySertch(int[] arr, int startIndex, int endIndex, int result) { if (startIndex > endIndex) { return -1; } int midIndex = (endIndex - startIndex) / 2 + startIndex; if (result > arr[midIndex]) { return BinarySertch(arr, midIndex + 1, endIndex, result); } else if (result < arr[midIndex]) { return BinarySertch(arr, startIndex, midIndex - 1, result); } else { return arr[midIndex]; } } #endregion
标签:endIndex,arr,C#,midIndex,int,算法,result,startIndex From: https://www.cnblogs.com/zjp959/p/17298569.html