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

}

相关推荐
爱读书的小胖23 分钟前
LeetCode 122:买卖股票的最佳时机 II(C)解题分析
算法
结局无敌24 分钟前
React Native for OpenHarmony 实战:三方库 react-native-modal-dialog 的鸿蒙化适配指南
深度学习·算法·react native·react.js·harmonyos
WJ.Polar26 分钟前
Java封装、继承、多态
java·开发语言
摇滚侠38 分钟前
Java 中如何表示负数,有符号和无符号的区别,补码的计算规则,char byte short int long 的范围
java·开发语言
OPEN-F1 小时前
ROS2系列教程:上位机建图与导航(原理综合)
算法·机器人
weixin_307779131 小时前
C++代码实现MATLAB中的fitrtree函数功能
开发语言·c++·算法·matlab
AI wins1 小时前
c++新增頭文件
c++
Shadow(⊙o⊙)1 小时前
仿muduo实现高并发服务器——事件就绪管理Channel.hpp
服务器·c++
爱读书的小胖1 小时前
Codewars:Rot13(C)解题分析
c语言·开发语言
tomwang03221 小时前
路径优化建模、优化算法分类及工程化小结
算法·数学建模·分类