C++ STL线性查找
来源:互联网 发布:硬盘不能识别数据恢复 编辑:程序博客网 时间:2024/06/06 13:19
#include <iostream>
#include <string>
#include <vector>
#include <iterator>
#include <algorithm>
#include <list>
#include <set>
#include <cstdlib>
using namespace std;
bool mod_greater ( int elem1, int elem2 )
{
if ( elem1 < 0 )
elem1 = - elem1;
if ( elem2 < 0 )
elem2 = - elem2;
return elem1 > elem2;
}
int main()
{
const int x=_MIN(3,-9,mod_greater);
cout<<x<<endl;
int a=3,b=3;
const int& result=_MIN(a,b);
cout<<result<<endl;
list<int> L(100);
list<int>::iterator iter1;
generate_n(L.begin(),100,rand); //为容器产生随机数
for(iter1=L.begin();iter1!=L.end();iter1++) //遍历
cout<<*iter1<<" ";
cout<<endl;
iter1=max_element(L.begin(),L.end()); //求最大元素
cout<<*iter1<<endl;
/******find()**************/
list<int> L1;
L1.push_back(1);
L1.push_back(5);
L1.push_back(3);
list<int>::iterator it=find(L1.begin(),L1.end(),5);
cout<<"the relult :"<<*it<<endl;
/******find_if()**************/
int A[]={4,1,0,3,2,0,6};
const int N=sizeof(A)/sizeof(int);
int* p=find_if(A,A+N,bind2nd(less<int>(),0));
cout<<"first:"<<p-A<<endl;
/******adjacent_if()**************/
int B[]={1,2,3,3,42,5};
const int M=sizeof(B)/sizeof(int);
const int* p1=adjacent_find(B,B+M,less<int>());//找到相邻<的元素位置
if(p1!=A+M)
cout<<"adjacent ele: "<<*p1<<endl;
return 0;
}
- C++ STL线性查找
- C++STL-线性结构
- 二分查找 C 、C++STL
- 线性查找,二分查找(C语言版)
- 线性查找算法的C语言实现
- C语言实现的线性查找和二分查找
- c查找算法——线性索引查找
- C++/STL/VC资源链接(查找方便)
- C++/STL/VC资源链接(查找方便)
- 线性查找
- 线性查找
- 线性查找
- 线性查找
- 线性查找
- 线性查找
- 线性查找
- 数据结构和算法系列 - c语言线性查找算法
- C/C++泛型编程(1)线性查找算法
- jdk环境变量
- Actionscript 3.0事件之Mouse_OVER,MOUSE_OUT,ROLL_OVER,ROLL_OUT的区别
- 再也不无聊的去灌水了
- 焦油坑与激情
- poj 3268 Silver Cow Party & zoj 2008 Invitation Cards
- C++ STL线性查找
- URL短地址压缩算法 微博短地址原理解析
- ActionScript 3.0 性能优化小知识(转)
- ASP.NET公有六种验证控件
- zoj 2416/hdu 1195 Open the Lock BFS基础
- codeforces#71 A Bus Game----DFS
- 电脑裸奔大法 part1
- botnet_20110501
- 找出circular的linked list的第一个元素