标签:private return 直接 public 递归 stat rgs turn else
直接看代码
package com.lm.digui;
public class GuiBinSort {
public static void main(String[] args) {
int[] arr = {1, 2, 3, 5, 8};
System.out.println(guibinNumber(arr, 0, arr.length - 1, 5));
}
private static int guibinNumber(int[] arr, int low, int high, int keyvalue) {
if (low < high) {
int mid = (low + high) / 2;
if (keyvalue == arr[mid]) {
return mid;
} else if (keyvalue < arr[mid]) {
return guibinNumber(arr, low, mid - 1, keyvalue);
} else if (keyvalue > arr[mid]) {
return guibinNumber(arr, mid + 1, high, keyvalue);
}
}
return -1;
}
}
标签:private return 直接 public 递归 stat rgs turn else
原文地址:https://www.cnblogs.com/limingming1993/p/12154004.html