标签:art lse pre 二分 orm int turn star 二分法查找
package SuanFa; import java.text.SimpleDateFormat; import java.util.Date; public class Demo1 { public static void main(String []args){ int []arr={1,3,5,7,9,11,12,13,15,16,18,19,20}; int a=rank(100,arr); System.out.println(a); System.out.println(new SimpleDateFormat("yyyy-MM-dd").format(new Date())); } static int rank(int key,int []arr){ int start=0; int end=arr.length-1; while (start<=end){ int mid=start+((end-start)/2); if(key<arr[mid])end=mid-1; else if(key>arr[mid])start=mid+1; else return mid; } return -1; } }
试用与有序集合
标签:art lse pre 二分 orm int turn star 二分法查找
原文地址:https://www.cnblogs.com/tiancai/p/9012924.html