#include <iostream>
using namespace std;
int BinarySearch(int data[],int length, int search)
{
int Hign = length;
int Low = 0;
int Mid = (Hign - Low) / 2;
while(Low <= Hign)
{
if ( search > data[Mid] )
{
Low = Mid;
Mid = (Hign + Low) / 2;
}
else if (search < data[Mid])
{
Hign = Mid;
Mid = (Hign + Low) / 2;
}
else
{
return Mid;
}
}
}
int main(int argc, char *argv[])
{
int data[] = {1,2,3,4,5,6};
cout<<BinarySearch(data,6,6)<<endl;
return 0;
}