ช่วยดูโค้ดตัวนี้หน่อยครับ มัน error

กระทู้คำถาม
#include <stdio.h>
#include <stdlib.h>
int binary_search(int data[],int search_item,int length)
{
int min =-1;
int max = length;
while(true)
{
if(data[(min+max)/2]==search_item)
return (min+max)/2;
if(min==max)
{
return -1;
}
if(data[(min+max)/2]<search_item)
{
min=(min+max)/2;
}
else{
max=(min+max)/2;
}

}

}

int main()
{
#define MAX_ARRAY_SIZE 100
int int_array[MAX_ARRAY_SIZE];
int count=0;
printf("please enter the numbers you want to sort -1 to end:\n");
while(true)
{
int input;
scanf("%i",&input);
if(input==-1)
break;
else
int_array[count]=input;
if(count>=MAX_ARRAY_SIZE)
exit(0);
count++;
}

int search;
printf("Plese enter the value that you need to Search");
scanf("%i",&search);

int result;
if((result=binary_search(int_array,search,count))==-1)
{
printf("the value %i does not found in the array\n",search);
}else{
printf("the value %i is located at index %i\n",search,result);
}
return 0;
}
แสดงความคิดเห็น
โปรดศึกษาและยอมรับนโยบายข้อมูลส่วนบุคคลก่อนเริ่มใช้งาน อ่านเพิ่มเติมได้ที่นี่