折半查找:代码:#include#includetypedef structint *elem;int length;sstable;int searchbin(sstable ST,int key)int low,high,mid;low=1;high=ST.length;while(low=high)mid=(low+high)/2;if(key=ST.elemmid) return(mid);else if(keyST.elemmid)high=mid-1;else low=mid+1;return(0);void main()int i,key,location;sstable ST;ST.elem=(int*)malloc(ST.length*sizeof(int);printf(“请输入表的长度:n“);scanf(“%d“,printf(“请输入待查找表中的元素:n“);for(i=1;i=ST.length;i+)scanf(“%d“,printf(“请输入要查找的元素:n“);scanf(“%d“,location=searchbin(ST,key);printf(“要查找的元素的位置为:%dn“,location);运行结果:见下页。