package com.cyjt97.bubbling; public class mid { public static void main(String[] args) { int arr[] = {11, 22, 33, 44, 55, 66, 77, 88, 99}; int index = binaSeash(arr, 99); System.out.println(index); } private static int binaSeash(int[] arr, int num) { int min = 0; int max = arr.length - 1; int mid; while (min <= max) { mid = (min + max) / 2; if (num > arr[mid]) { min = mid + 1; } else if (num < arr[mid]) { max = mid - 1; } else { return mid; } } return -1; } }
标签:arr,java,进阶,min,46,mid,int,static,binaSeash From: https://www.cnblogs.com/wencaiguagua/p/17230524.html