list容器查找算法find(),
来源:互联网 发布:飞鸽传书 软件 编辑:程序博客网 时间:2024/06/05 22:54
#include <list>
#include <iostream>
#include <algorithm>//注意需要这个库
using namespace std;
int main()
{
list<int> l;
for(size_t i=1; i < 11; ++i)
{
l.push_back(i);
}
list<int>::iterator it;
for (it=l.begin(); it!=l.end();++it)
{
cout << *it << " ";
}
cout <<endl;
//采用find()查找算法在链表中查找;
it = find(l.begin(),l.end(),5);
if (it != l.end())
{
cout << "find it" << endl;
}
else
{
cout << "not find it" << endl;
}
cin.get();
return 0;
}
#include <iostream>
#include <algorithm>//注意需要这个库
using namespace std;
int main()
{
list<int> l;
for(size_t i=1; i < 11; ++i)
{
l.push_back(i);
}
list<int>::iterator it;
for (it=l.begin(); it!=l.end();++it)
{
cout << *it << " ";
}
cout <<endl;
//采用find()查找算法在链表中查找;
it = find(l.begin(),l.end(),5);
if (it != l.end())
{
cout << "find it" << endl;
}
else
{
cout << "not find it" << endl;
}
cin.get();
return 0;
}
- list容器查找算法find(),
- STL之vector,数组线性容器array,list容器,算法find,find_if,bind1st,仿函数
- STL中的find,find_if函数(对类、容器(vector、list)进行查找)
- 在list中查找find
- STL 查找vector容器中的指定对象:find()与find_if()算法
- c++ find 在容器中查找元素
- find算法函数查找示例
- 查找list容器中的某一个值
- 用find/find-all match方式查找list元素
- STL中Vector容器Find的使用(int查找)
- STL标准函数find进行vector list链表查找
- C++ STL 算法:查找算法(1)find、find_if
- STL_算法_查找算法(find、find_if)
- 查找(find)
- find 查找
- List 容器
- List 容器
- list容器
- 一个五位数ABCDE乘与4为EDCBA五个数还不重复
- C++去掉注释
- 编写函数,要求输入年月日时分秒,输出该时间的下一秒
- Antenna Placement poj3020
- deque双端队列容器前、中、尾部插入
- list容器查找算法find(),
- map容器创建、元素插入和前向遍历访问
- java 笔记1
- multimap对象创建、元素插入
- queue队列容器入队,出队,读取队首元素,队尾元素,判断是否为空
- reverse反向排列
- set容器元素的插入和中序遍历,反向遍历,反向迭代器reverse_iterator和rbegin(),rend();
- sort默认升序排序
- stack容器的用法:入栈、出栈、访问栈顶元素,判断是否为空