#include <stdio.h> int main ( ) { int a[10]={ 0,4,5,6,13,27,50,90,100,999} ; int low ,high,mid, x ; printf(" 输入待查的元素:"); scanf("%d",&x); low=0 ; high=9 ; while(low<=high) { mid=(low+high)/2 ; if(a[mid]==x) { printf("%d 的位置是:%d ",x,mid); break; } if(a[mid]<x) low=mid+1 ; else high=mid-1; } if(low>high) printf("%d不存在 ",x) ; }