查找算法3-2
来源:互联网 发布:linux回到根目录命令 编辑:程序博客网 时间:2024/05/15 08:39
#include <iostream>#include <algorithm>#include <vector>using namespace std;bool checkEven(int elem, bool even){if (even)return elem % 2 == 0; // 查找偶数elsereturn elem % 2 == 1; // 查找奇数}int main(){vector<int> ivec;for (int i = 1; i <= 9; ++i)ivec.push_back(i);for (vector<int>::iterator iter = ivec.begin(); iter != ivec.end(); ++iter)cout << *iter << ' ';cout << endl;bool checkEvenArgs[3] = { true, false, true }; //查找偶数基数偶数。vector<int>::iterator pos;pos = search(ivec.begin(), ivec.end(), checkEvenArgs, checkEvenArgs+3, checkEven);if (pos != ivec.end())cout << "找到了,位置:" << distance(ivec.begin(), pos) + 1 << endl;elsecout << "没有找到," << endl;return 0;}
0 0
- 查找算法3-2
- (3) 查找算法 --- 顺序查找 折半查找
- 查找算法(2)--二分查找算法
- STL算法------查找3
- 查找算法3
- 二分查找算法2
- 2分查找算法
- STL算法------查找2
- 查找算法2
- 查找算法总结(3)--二叉查找树
- 查找算法(3)--二叉树查找
- 2分查找(折半查找)算法
- 十.用C语言实现查找算法 (1)顺序查找;(2)二分查找(折半查找);(3)二叉排序树;(4)哈希查找
- 查找的3种算法
- 查找算法学习(3)
- (2)分块查找算法
- 字符串查找(2)KMP算法
- 查找算法总结(2)--哈希表
- C++设计模式之桥接模式
- Fiddler(二) - 使用Fiddler做抓包分析
- poj1020 dfs
- Jenkins+Gradle实现android开发持续集成、打包
- C++编码规范
- 查找算法3-2
- 141. Linked List Cycle
- Activity之间的数据交互
- R语言实现常用算法
- Android事件传递机制(一)
- 航电OJ-2544最短路
- Scrapy见面第五天
- 对移动医疗浅陋的理解
- 智能指针下的多态