- #define MaxSize 50
- typedef strcut{
- ElemType data[MaxSize];
- int length;
- }Sqlist;
-
- bool binary_search(Sqlist L,ElemType k){
- int low=0,high=L.length-1,mid;
- while(low<=high){
- mid=(low+high)/2;
- if(k==L.data[mid]) //插入值与中间值相同则返回真
- return true;
- else if(k
data[mid]) - high=mid-1;
- else
- low=mid+1;
- }
- return false; //查找结束也没找到返回假
- }