c++ find_if 算法

#include <iostream>

#include <string>

#include <fstream>

#include <vector>

#include <algorithm>

#include <deque>

#include <stack>

#include <queue>

#include <list>

#include <set>

#include <map>

#include <functional>

using namespace std;

class GreaterFive

{

public:

bool operator()(int a)

{

return a > 5;

}

};

void test01()

{

vector<int> v1;

for(int i = 0; i < 10; i++)

{

v1.push_back(i);

}

vector<int>::iterator it = find_if(v1.begin(), v1.end(), GreaterFive());

if(it == v1.end())

{

cout << "dont" << endl;

}

else

{

cout << "find" << *it << endl;

}

}

int main()

{

test01();

return 0;

system("pause");

}

相关推荐
lly2024061 小时前
Bootstrap 警告框
开发语言
2601_949146532 小时前
C语言语音通知接口接入教程:如何使用C语言直接调用语音预警API
c语言·开发语言
你撅嘴真丑2 小时前
第九章-数字三角形
算法
曹牧2 小时前
Spring Boot:如何测试Java Controller中的POST请求?
java·开发语言
在路上看风景2 小时前
19. 成员初始化列表和初始化对象
c++
KYGALYX2 小时前
服务异步通信
开发语言·后端·微服务·ruby
uesowys2 小时前
Apache Spark算法开发指导-One-vs-Rest classifier
人工智能·算法·spark
zmzb01032 小时前
C++课后习题训练记录Day98
开发语言·c++
ValhallaCoder2 小时前
hot100-二叉树I
数据结构·python·算法·二叉树
董董灿是个攻城狮2 小时前
AI 视觉连载1:像素
算法