public class Demo {
static int q1(int[] sz,int low,int high,int target) {
// TODO Auto-generated method stub
if (low>high)
return -1;
int mid = (low+high)>>>1;
int midvlu = sz[mid];
if(midvlu>target) {
return q1(sz,low,mid-1, target);
}else if (midvlu<target) {
return q1(sz,mid+1,high, target);
} else
return mid;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String str = sc.nextLine();
String str1 = str.substring(1, str.length()-1);
String[] str3 = str1.split(",");
int[] in = new int[str3.length];
for (int i = 0; i < str3.length; i++) {
in[i] = Integer.parseInt(str3[i]);
}
//拿到数组
System.out.println(q1(in,0,in.length-1,7));
sc.close();
}
}
03-19
993
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
05-17
4889
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-23
7044
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
04-03
434
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
03-25
3558
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
01-04
2907
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)