#include using namespace std; #define OK 1 #define ERROR 0 #define MAXSIZE 100 typedef int KeyType; typedef struct { int elem[MAXSIZE]; int length; }SSTable; //建立一个顺序表来存放元素 int Search_Bin(SSTable ST,KeyType key) { int low,high,mid; low=1; high=ST.length; while(low<=high) { mid=(low+high)/2; //折半,并且输出比较的元素 cout<<" "<key) //如果关键字大于查找的数字,则往小的移动 high=mid-1; else if(ST.elem[mid]>ST.length; cout<<"请输入有序表的元素"<>ST.elem[i]; } cout<<"请输入要查找的元素:"<>n; cout<<"比较的元素有:"; a=Search_Bin(ST,n); if(a>=0) cout<<"\n查找元素的下标是:"<