Aug 28

【Code§C/C++】二分查找函数   不指定

felix021 @ 2007-8-28 22:01 [IT » 程序设计] 评论(2) , 引用(0) , 阅读(7862) | Via 本站原创 | |
【Code§C/C++】二分查找函数  


int find(int R[],int low,int high,int t)
{
  int mid;
  if(high-low<=1)
  {
    if(t==R[high])return high;
    if(t==R[low])return low;
    return -1;  
  }  
  mid=(low+high)/2;
  if(t<=R[mid])return find(R,low,mid,t);
  else return find(R,mid+1,high,t);
}





欢迎扫码关注:




转载请注明出自 ,如是转载文则注明原出处,谢谢:)
RSS订阅地址: https://www.felix021.com/blog/feed.php
11
2008-6-27 19:53
很麻烦
很难看懂
QQ160228896
请指教
11
2008-6-27 19:49
grin
怎么没有调用啊
felix021 回复于 2008-6-27 21:25
#include<stdio.h>

int main(){
  int a[10] = {0,1,2,3,4,5,6,7,8,9};
  printf("%d\n", a, 0, 9, 4);
  return 0;
}
分页: 1/1 第一页 1 最后页
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   *非必须
网址   电邮   [注册]