#include<iostream.h> void main() { int a[]={1,2,3,4,5,6,7,8,9,10}; int high=sizeof(a)/sizeof(int)-1,low=0,mid; while(1) { mid=(high+low)/2; if(a[mid]<9&&low<=high) { low=mid+1; } else if(a[mid]>9&&low<=high) { high=mid-1; } else if(a[mid]==9&&low<=high) { cout<<"所查关键字9为顺序表中第"<<mid+1<<"个位置"<<endl; break; } else { cout<<"查找失败"<<endl;break; } } }