#include
using namespace std;
int binsrch(int num[], int len, int target){
int lower = 0;
int upper = len-1;
int mid=0;
while(lower <= upper){
mid = (lower + upper) / 2;
if(target > num[mid])
lower = mid + 1;
else if(target < num[mid])
upper = mid - 1;
else
return mid + 1; //這是"找到", 你要直接回傳mid
}
return mid; //這是"找不到", 你要回傳-1或0
}