public class Testclass { public static void main(String []args) { int [] id = {0,1,2,3,4,5,6,7,8,9}; int key = 7; int first = 0; int last = id.length-1; int middle; int position = -1; boolean found = false ; int count =0; while (!found && first <= last) { count++; middle = (frist + last)/2; if (id[middle]==key){ found = true; } else if (id[middle]>key){ last = middle-1; } else first = middle+1; } System.out.print(count); } } Ö´Ðнá¹ûÊÇʲô£¿2,ÔõôÁË£¿ middle = (frist + last)/2; ¸ÄΪ£ºfirst µÄÈ·ÊÇд´íÁË¡£¡£¡££¡ middle = (frist + last)/2; ¸ÄΪ£ºfirst