#include <iostream>
using namespace std;
template <class T>
class BinarySearch{
public:
//默认为升序排列数组
int Position(T*a,int low,int high,T x)
{
if(low==high)
{
if(x==a[low]) return low;
else return -1;//如果找不到返回-1
}
int mid=(low+high)/2;
if(x==a[mid]) return mid;
if(x<a[mid]) return Position(a,low,mid-1,x);
else return Position(a,mid+1,high,x);
}
};