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");

}

相关推荐
小O的算法实验室11 分钟前
2026年CIE,优化客货协同运输:综合地铁系统的列车容量动态分配
算法
Coder_Shenshen1 小时前
西门子S7CommPlus协议鉴权算法原理与流程详解
网络·后端·算法
大圣编程2 小时前
Python中continue语句的用法是什么?
开发语言·前端·python
硕风和炜2 小时前
【LeetCode: 2492. 两个城市间路径的最小分数 + DFS】
java·算法·leetcode·深度优先·dfs·bfs·并查集
upgrador2 小时前
基础知识:C++ STL构造函数的左闭右开惯例及其实现原理
开发语言·c++
我是一颗柠檬3 小时前
【Java项目技术亮点】加权轮询负载均衡算法
java·算法·负载均衡
灯厂码农3 小时前
C语言动态内存分配完全指南(malloc、calloc、realloc、free)
java·c语言·算法
yoothey3 小时前
报废审批流规则引擎设计——责任链模式完整实现
linux·开发语言·bash
geovindu3 小时前
python: Functional Options Pattern
开发语言·后端·python·设计模式·惯用法模式·函数式选项模式
wuyk5553 小时前
24. C 语言模块化:不是拆几个.c 文件那么简单
c语言·开发语言·stm32·单片机