快速查找得出索引位置
来源:互联网 发布:c语言删除文件内容 编辑:程序博客网 时间:2024/06/05 16:15
#include<iostream>
using namespace std;
int Find(int ar[],int low,int high,int key)
{
if(low>high)
return -1;
int mid = (low+high)/2;
if(ar[mid] == key)
return mid;
else if(key<ar[mid])
return Find(ar,low,mid-1,key);
else
return Find(ar,mid+1,high,key);
}
void main()
{
int ar[]={1,23,45,67,90,123,456,678,900,1000};
int key;
cout<<"intput key:";
cin>>key;
int n = sizeof(ar) / sizeof(int);
int low = 0;
int high = n-1;
int index=Find(ar,low,high,key);
cout<<"index ="<<index<<endl;
}
1 0
- 快速查找得出索引位置
- 查找子串的索引位置算法
- java数组中根据元素查找位置 索引
- android自定义View----通讯录导航栏(快速查找索引)
- 使用boost查找区分大小写查找,查找一个字符串在另外一个字符串的位置,返回索引。
- 索引查找
- 索引查找
- 索引查找
- 索引查找
- 索引查找
- 为什么索引能快速查找数据行及索引也涉及锁的机制
- 索引表 索引查找
- 查找之索引查找
- 算法---查找子串第一次出现的位置索引(indexOf)
- SQL Server 中查找字符串在另一字符串中的索引位置问题
- 查找list中的重复数据,并得到重复数据索引位置
- 一个字符串中查找另一个字符出现的全部索引位置(JAVA)
- monodb的索引--自我测试得出的结论
- fastdfs
- Linux Platform驱动模型(一) _设备信息
- spring-boot整合redis 总结
- ListView源码分析
- Linux 服务器添加双线 修改静态路由
- 快速查找得出索引位置
- Java String 编码格式转换
- centos 7 lamp+lnmp环境
- Handler.removeMessages的作用
- webpack 启动后自动打开浏览器插件:open-browser-webpack-plugin
- Uncaught RangeError: Invalid array length 问题解决
- Installation failed with message INSTALL_FAILED_NO_MATCHING_ABIS: Failed to extract native libraries
- H5常用的底层方法---加载页面的封装
- 设计模式在综合前置中的运用(四)--原型模式