귀속 이분법

2035 단어 이분법
public class ttt {
public static int[] ii = new int[]{1,2,3,4,5,6,7,8,9,10,11};
public static int start = 0;
public static int end = 0;
public static int middle = 0;
String n = "";
public void twoF(int aa,int m){
n += (m+1+"-");
if(aa!=ii[m]){

if(ii[m]>aa){
end = m;
m = (start+end)/2;
}
if(ii[m]<aa){
start = m;
m = (start+end)/2;
}
twoF(aa,m);
}else{
System.out.println(n);
}
}
public static void main(String[] args) {
start = 0;
end = ii.length;
middle = (start+end)/2;
new ttt().twoF(11,middle);
}
}

자기가 똑똑히 본 것을 써라...

좋은 웹페이지 즐겨찾기