#include <stdio.h>
int main() {
int data[6] = {10, 20, 30, 40, 50, 60};
int num = 45;
int low,high,mid;
low = 0;
high = sizeof(data)/sizeof(int) - 1;
while(low <= high){
mid = (low + high) / 2;
if(num == data[mid]){
printf("%d ",mid);
return 0;
}
else if(num > data[mid]){
low = mid + 1;
}
else if(num < data[mid]){
high = mid - 1;
}
}
printf("찾는 값이 없습니다");
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: