코드를 맞게 짠것같은데 원하는 답이안나옵니다..ㅜㅜ
고양이
public static void main(String[] args)
{
int[] array = {78,34,55,16,98,33,24,41,67,39};
InsertionSort(array);
String searchNumber=;
System.out.println(Enter number to search : );
try
{
BufferedReader br = new BufferedReader (new InputStreamReader (System.in));
searchNumber = br.readLine().trim();
}
catch (IOException e) { e.printStackTrace(); }
int number = Integer.parseInt(searchNumber);
int start,end;
int middle= (0+(array.length-1))/2;
do{
if(numberarray[middle])
{
start = middle+1;
middle = (array.length-1+start)/2;
}
else if(numberarray[middle])
{
end= middle-1;
middle=(0+end)/2;
}
else if(number==array[middle])
break;
} while(number != array[middle]);
System.out.println(Found at + middle);
}
}
여기까지가 제가 쓴 코드구요.. 답이 잘 안나오네요 ㅜㅜ뭐가 잘못된건지좀 알려주세요 ㅜㅜ감사합니다~