© zyh1578814923 中级黑马 / 2015-11-21 22:18 / 2560 人查看 / 3 人回复 / 0 人收藏 转载请遵从CC协议 禁止商业使用本文
8黑马币
最佳答案ublic class erfen {
/**
* @param args
*/
public static void main(String[] args) {
int[] arr = {11,22,33,66,88,99};
System.out.println(getIndex(arr,55));
}
public static int getIndex(int[] arr,int x){
int min = 0;
int max = arr.length-1;
int mid =(min+max)/2;
while (arr[mid] != x) {
if (arr[mid] < x) {
min =mid+1;
}else if (arr[mid] > x) {
max = mid-1;
...
| |
| |
| |