折半查找法
来源:互联网 发布:梵语发音软件 编辑:程序博客网 时间:2024/06/03 17:45
#include <stdio.h>int halfsearch(int a[],int n,int x);int main(){ int a[10]={4,5,7,8,10,12,16,18,20,30},n,x; scanf("%d",&x); if(n=halfsearch(a,10,x)!=-1) printf("%d %d",x,n); else ; return 0; }int halfsearch(int a[],int n,int x){ int s=0,e=n-1,m; while(s<=e) { m=(s+e)/2; if(a[m]==x) return m; else if(x>a[m]) s=m+1; else e=e-1; } return -1;}
- 折半查找法(递归)
- 折半查找法
- 汇编折半查找法
- 折半查找法
- 折半查找法
- 折半法查找
- 折半查找法
- 折半查找法
- 折半查找法C++
- 折半查找法
- JAVA折半查找法
- 折半查找法
- NSArray 折半查找法
- 折半查找法
- 折半查找法
- 折半查找法
- 折半查找法
- 算法:折半查找法
- ubuntu12.04的NFS配置
- 定时自动按键
- check out the psk from wpa wireless network
- 乱码
- 基于 OSGi 的面向服务的组件编程
- 折半查找法
- Objective-C中的NSObject对象经常使用到的方法
- 二维数组求最大值
- 判断素数
- 判断回文数
- 递归计算阶乘
- 计算m的m次方倒数的和
- How to 共用体
- 2个问题