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

}

相关推荐
阿童木写作3 分钟前
Python批量翻译亚马逊商品图实战教程
开发语言·python·xcode
惊讶的猫11 分钟前
CLGSI
人工智能·算法·机器学习
会飞的大鱼人1 小时前
一文搞懂 Java HashSet:把它想成游乐园里只允许一次入场的盖章名单
java·开发语言·windows
ysa0510301 小时前
【板子】二分答案(最大最小?)
c++·笔记·算法·板子
科技之门1 小时前
百公里管网漏损分级定位实战方案2026
前端·人工智能·算法
木木子222 小时前
# 猜数字游戏 — HarmonyOS交互逻辑与随机算法实现
算法·游戏·华为·交互·harmonyos
jiay22 小时前
【.net10】顶级程序语句
java·开发语言
stolentime2 小时前
SP8549 MAIN75 - BST again题解
c++·算法·二叉树·深度优先·图论·记忆化搜索·组合数学
淼澄研学2 小时前
Python进阶实战:深入解析推导式与生成器等5大核心特性
开发语言·python
ziguo11222 小时前
C/C++ 错误处理全解:从 errno 到 C++ 异常
linux·c语言·c++·windows·visual studio