public class De {
//寻找一个数组中一个数据是该数组的第几个元素
public static int binarSearch (int[] array,int key){
int left = 0;
int right = array.length-1;
while (left <= right ) {
int mid = ( left + right )/2;
if (array[mid] < key){
left = mid+1;
}else if(array[mid] > key){
right = mid-1;
}else {
return mid;
}
}
return -1;// 没有找到该数
}
public static void main3(String[] args) {
int[] array = new int[10000];
for (int i = 0; i < 10000 ; i++) {
array[i] = i;
}
int ret = binarSearch(array,5644);
System.out.println(ret);
//冒泡法排序
//优化:
public static void pubSort (int[] array) {
if (array == null || array.length == 0){
retur