int binarysearch(int *arr, int n, int a)//n-元素总个数,a-目标元素
{
int left = 0;
int right = n + 1;
while (right - left != 1)
{
int mid;
mid = (left + right) / 2;
if (arr[mid] < a)
left = mid;
else
right = mid;
}
return right;
}