#include<stdio.h> int main() { int b[10]={1,2,3,4,6}; int a; printf("Please input the number:\n"); scanf("%d",&a); printf("This number is a[%d]!\n",serch(a,b,5)); } int serch(int x,int v[],int n) { int low,mid,high;
low = 0;
high = n-1; while(low<=high){
mid=(low+high)/2; if(x<v[mid])
high = mid-1; elseif(x>v[mid])
low = mid+1; elseif(x==v[mid]) return mid; } return-1; }