#include<stdio.h>
#include<stdlib>
int BinarySearch(int arr[],int size,int toFind){
int left=0;
int right = size - 1;//最后一个元素的下标;
while(left<=right){
int mid=(left+right)/2;
if(arr[mid] > toFind){
right = mid - 1;
}else if(arr[mid] < toFind){
left = mid + 1;
}else{
return mid;}
}
return -1;
}
int main(){
int arr[4] = {1,2,3,4};
int size = sizeof(arr)/sizeof(arr[0]);
int ret = BinarySearch(arr, size, 1);
}