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

}

相关推荐
apcipot_rain3 小时前
C++转Java日记(04)
java·开发语言·c++
NEFU_Jyj3 小时前
牛客周赛R168
算法
云和数据.ChenGuang4 小时前
LangGraph 异步 Node 的设计与写法实践
开发语言·人工智能·python·机器学习·php
WL学习笔记5 小时前
vector模拟实现
c++
蜗牛一步步往上爬7 小时前
第十六章 C++语言在深度学习中的应用
开发语言·c++·深度学习
张张123y9 小时前
DSH 插件调试避坑:client.js 设置面板、热重载与高频报错排查表
开发语言·javascript·人工智能·开源·ecmascript·后端开发·ai agent
Navigator_Z11 小时前
LeetCode //C - 1317. Convert Integer to the Sum of Two No-Zero Integers
c语言·算法·leetcode
wo_jack11 小时前
C++ 入门笔记(十六):第16课 vector 模拟实现十问十答 —— 从三指针到迭代器失效
c++·后端·面试·stl·vector
D e re k ZH12 小时前
C++ 标准库算法全景指南
数据结构·c++·算法