二分法查找

二分法查找:前提条件:数组必须是有序数组

int findVlaue = intValue;

int min = 0 , max = arr.length-1,mid;

while(min

mid = (min+max)>>1;

if(findVlaue>arr[mid]){

min = mid+1;

}

else if(findVlaue

max = mid -1;

}

else System.out.println("zhaodaole");

}

System.out.println("meizhaodao");

你可能感兴趣的:(二分法查找)