ch7_2.txt
上传用户:lgb298
上传日期:2013-03-22
资源大小:1025k
文件大小:0k
源码类别:

软件工程

开发平台:

C/C++

  1. int binsrch(JD r[],int n,int k)
  2. {  int low,high,mid,found;
  3.    low=1;  high=n; found=0;
  4.    while((low<=high)&&(found==0))
  5.    {  mid=(low+high)/2;
  6.       if(k>r[mid].key)  low=mid+1;
  7.       else if(k==r[mid].key)  found=1;
  8.       else   high=mid-1;
  9.    }
  10.    if(found==1)
  11.       return(mid);
  12.    else
  13.       return(0);
  14. }