/*-------------------------------------------------------
编程:采用二分法从数组中查找key值,若存在则返回对应的下标,否则返回-1。
-------------------------------------------------------*/
#include <stdio.h>
int fun(int a[],int n,int key)
{
int low,high,mid;
low=0;
high=n-1;
while (low<=high)
{
/**********Program**********/
/********** End **********/
}
return -1;
}
void main()
{
int a[10]={1,2,3,4,5,6,7,8,9,10};
int b,c;
b=4;
c=fun(a,10,b);
if (c==1)printf("not found");
else printf("position %d\n",c);
}