第14周项目1(1)-验证折半查找算法
来源:互联网 发布:ug10.0拆电极视频编程 编辑:程序博客网 时间:2024/04/29 11:44
/** Copyright (c)2016,烟台大学计算机与控制工程学院* All rights reserved.* 文件名称:项目1-1.cbp* 作 者:孟琪琪* 完成日期:2016年12月1日* 版 本 号:v1.0* 问题描述:验证折半查找算法* 输入描述:无* 程序输出:测试数据*/
#include<iostream>using namespace std;int main(){int low=0,high,n;int a[100];int i=0,f;cout<<"Please input the number of data and what data do you want to find"<<endl;while(cin>>n){cin>>f;high=n-1;while(i<n){cin>>a[i];i++;}int mid;while(low<=high){mid=(low+high)/2;if(a[mid]==f){cout<<"find in the postion "<<mid+1<<endl;break;}if(a[mid]>f){high=mid-1;}else{low=mid+1;}}if(low>high){cout<<"can't find it"<<endl;}cout<<"Please input the number of data and what data do you want to find"<<endl;low=0;i=0;}return 0;}
知识点总结:折半查找算法的验证。
0 0
- 第14周项目(1)-验证折半查找算法
- 第14周 项目1 - 验证算法 - 折半查找算法
- 第14周 项目1-(1)验证折半查找算法
- 第14周项目1(1)验证折半查找算法
- 【第14周 项目1 - (1)验证折半查找算法】
- 第14周 项目1 - (1)验证折半查找算法
- 【第14周 项目1 - (1)验证折半查找算法】
- 第13周项目1- 验证折半查找算法(1)
- 第14周项目1-(1)验证折半查找算法
- 第14周项目1-(1)验证折半查找算法
- 第14周项目1-验证折半查找算法(1)
- 第14周项目1(1) 验证折半查找算法
- 第14周项目1-(1)验证折半查找算法
- 第14周SHH数据结构-【 项目1-(1)验证折半查找算法 】
- 第14周项目1-(1)验证折半查找算法
- 第14周项目1-(1)验证折半查找算法
- 第14周项目1-(1)验证折半查找算法
- 第14周项目1(1)-验证折半查找算法
- 记录常用的Git操作命令
- playframe 项目的新建和导入
- 为什么选择Stack overFlow
- 浅谈SDN和NFV之间的关系
- 【第十四周 项目1-验证折半查找算法】
- 第14周项目1(1)-验证折半查找算法
- ios 7 专场2
- 第十四周项目1线性表得折半查找
- 第十三周【项目四 Floyd算法实现】
- 水波纹效果之仿支付宝咻一咻
- spring-security 3.0.X, 让ajax login和普通login共存
- Dcloud mui初级入门资源
- 第14周项目1-(1)验证折半查找算法
- 润乾报表中如何动态的打开不同的XML数据集