int bisearch_max(vector<int> &ar,int b,int e,int a)//寻找目标元素的最大序号
{
int minIndex = b, maxIndex = e, midIndex;
while (minIndex < maxIndex -1)
{
midIndex = minIndex + (maxIndex - minIndex) / 2;
if (ar[midIndex] <= a)
minIndex = midIndex;
else
maxIndex = midIndex;
}
if (ar[maxIndex] == a)
return maxIndex;
else if (ar[minIndex] == a)
return minIndex;
else
return -1;
}
int bisearch_min(vector<int> &ar, int b, int e, int a)//寻找目标元素的最小编号
{
int minIndex = b, maxIndex = e, midIndex;
while (m