摘要: 折半查找的应用 public static void main(String[] args) { int[] arr = {4,6,6,7,8,9,10}; System.out.println(getIndexOf(arr,5)); } public static int getIndexOf(i 阅读全文
posted @ 2020-03-08 23:55 hongxiao2020 阅读(828) 评论(0) 推荐(0)
摘要: public static void main(String[] args) { int[] arr = {0,1,2,3,4,5,6,7,8,9,10}; System.out.println(halfSearch_2(arr,5)); } public static int halfSearch 阅读全文
posted @ 2020-03-08 23:40 hongxiao2020 阅读(261) 评论(0) 推荐(0)
摘要: 只要有一轮没有发生交换,说明数据的顺序已经排好,没有必要继续进行循环下去了。 public class BubbleDemo { public static void main(String[] args) { int[] arr = {1,3,5,7,9,2,4,6,8,0}; sort(arr) 阅读全文
posted @ 2020-03-08 22:36 hongxiao2020 阅读(407) 评论(0) 推荐(0)
摘要: 如果元素已经在该在的位置上就不需要再交换位置了。 public class SelectDemo { public static void main(String[] args) { int[] arr = {1,3,5,7,9,2,4,6,8,0}; sort(arr); for (int i: 阅读全文
posted @ 2020-03-08 22:28 hongxiao2020 阅读(296) 评论(0) 推荐(0)
摘要: 1、元素类型[] 数组名 = new 元素类型[元素个数] 2、元素类型[] 数组名 = new 元素类型[]{元素,元素,元素,元素...} 3、元素类型[] 数组名 = {元素,元素,元素,元素...} 阅读全文
posted @ 2020-03-08 18:10 hongxiao2020 阅读(184) 评论(0) 推荐(0)
摘要: 概念:在同一个类中,允许存在一个以上的同名函数,只要他们的参数个数或者参数类型不同即可。 特点:与返回值无关,只看参数列表。 阅读全文
posted @ 2020-03-08 17:05 hongxiao2020 阅读(157) 评论(0) 推荐(0)