[PTA] 数据结构与算法题目集 6-10 二分查找
Position BinarySearch(List L, ElementType X)
{
int beg = 1;
int end = L->Last;
while (beg <= end)
{
int mid = (beg + end) / 2;
if (L->Data[mid] == X)
return mid;
else if (L->Data[mid] < X)
beg = mid + 1;
else
end = mid - 1;
}
return NotFound;
}