赞
踩
public class TestMain { public static void main(String[] args) { //添加随机数到数组 int[] randomArray = new int[1000]; for (int i = 0; i < randomArray.length; i++) { int randDomNum = new Random().nextInt(100)+1; randomArray[i]=randDomNum; } //排序(二分法前提是有序) Arrays.sort(randomArray); //打印输出方便对比查看出现的次数 for (int i = 0; i < randomArray.length; i++) { System.out.println(randomArray[i]+" "+i); } //出现的次数 int count = 0; //最小数下标 int minIndex = 0; //最大数下标 int maxIndex = randomArray.length-1; System.out.println("请输入你要查找的数:"); Scanner sc = new Scanner(System.in); //控制台输入的数 int inp
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。