public class Day13_Array {
public static int getIndex(int[] arr, int value) {
int min = 0;
int max = arr.length - 1;
int mid = (min + max) / 2;
if (arr[value] < min)
return -1;
if (arr[value] > max)
return -1;
//对数组进行折半查找 1
public static int find(int[] arr,int key){
int min=0;
int max=arr.length-1;
int mid=(min+max);
while(key!=arr[mid])
{
if(key>arr[mid])
min=mid+1;
else if(key<arr[mid])
max=mid-1;
if (max<min){
return -1;
}
mid=(max+min)/2;
}
return mid;
}
//对数组进行折半查找 2
public static int find_2(int[] arr,int key){
int min=0;
int max=arr.length-1;