int BinarySearch(int a[], const int &x, int lef, int rig)
{
if(lef <= rig)
{
int mid = (lef + rig) /2;
if(x == a[mid])
return mid;
else if(x > a[mid])
return BinarySearch(a, x, mid+1, rig);
else
return BinarySearch(a, x, lef, mid-1);
}
}
转载于:https://www.cnblogs.com/Nicholastwo/p/9356916.html