Iterator与LIstIterator接口在java中的区别有哪些
202
2023-04-24
Java 选择、冒泡排序、折半查找(实例讲解)
如下所示:
//选择排序对数据进行升序排序
public static void selectRmLRmxpLWSortArray(int[] arr){
for(int i = 0; i for(int j = i+1;j if(arr[i]>arr[j]){RmLRmxpLW int temp = arr[j]; arr[j] = arr[i]; arr[i] = temp; } } } } //冒泡排序对数据进行升序排序 public static void bubbleSortArray(double[] arr){ for(int i = 0;i for(int j = 0;j if(arr[j]>arr[j+1]){ double temp = arr[j+1]; arr[j+1] = arr[j]; arr[j] = temp; } } } } public static int binarySearch(int[] arr,int key){ int max,min,mid; max = arr.length-1; min = 0; while(min<=max){ mid = (max+min)/2; if(key>arr[mid]){ min = mid+1; }else if (key max = mid-1; }else{ return mid; } } return -1; }
for(int j = i+1;j if(arr[i]>arr[j]){RmLRmxpLW int temp = arr[j]; arr[j] = arr[i]; arr[i] = temp; } } } } //冒泡排序对数据进行升序排序 public static void bubbleSortArray(double[] arr){ for(int i = 0;i for(int j = 0;j if(arr[j]>arr[j+1]){ double temp = arr[j+1]; arr[j+1] = arr[j]; arr[j] = temp; } } } } public static int binarySearch(int[] arr,int key){ int max,min,mid; max = arr.length-1; min = 0; while(min<=max){ mid = (max+min)/2; if(key>arr[mid]){ min = mid+1; }else if (key max = mid-1; }else{ return mid; } } return -1; }
if(arr[i]>arr[j]){RmLRmxpLW
int temp = arr[j];
arr[j] = arr[i];
arr[i] = temp;
}
}
}
}
//冒泡排序对数据进行升序排序
public static void bubbleSortArray(double[] arr){
for(int i = 0;i for(int j = 0;j if(arr[j]>arr[j+1]){ double temp = arr[j+1]; arr[j+1] = arr[j]; arr[j] = temp; } } } } public static int binarySearch(int[] arr,int key){ int max,min,mid; max = arr.length-1; min = 0; while(min<=max){ mid = (max+min)/2; if(key>arr[mid]){ min = mid+1; }else if (key max = mid-1; }else{ return mid; } } return -1; }
for(int j = 0;j if(arr[j]>arr[j+1]){ double temp = arr[j+1]; arr[j+1] = arr[j]; arr[j] = temp; } } } } public static int binarySearch(int[] arr,int key){ int max,min,mid; max = arr.length-1; min = 0; while(min<=max){ mid = (max+min)/2; if(key>arr[mid]){ min = mid+1; }else if (key max = mid-1; }else{ return mid; } } return -1; }
if(arr[j]>arr[j+1]){
double temp = arr[j+1];
arr[j+1] = arr[j];
arr[j] = temp;
}
}
}
}
public static int binarySearch(int[] arr,int key){
int max,min,mid;
max = arr.length-1;
min = 0;
while(min<=max){
mid = (max+min)/2;
if(key>arr[mid]){
min = mid+1;
}else if (key max = mid-1; }else{ return mid; } } return -1; }
max = mid-1;
}else{
return mid;
}
}
return -1;
}
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~