c++ for_each算法

#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;

void print(int a)

{

cout << a << " ";

}

class print02

{

public:

void operator()(int a)

{

cout << a << " ";

}

};

void test01()

{

vector<int> v1;

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

{

v1.push_back(i);

}

for_each(v1.begin(), v1.end(), print);

cout << endl;

for_each(v1.begin(), v1.end(), print02());

cout << endl;

}

int main()

{

test01();

return 0;

system("pause");

}

相关推荐
551只玄猫2 小时前
【数学建模 matlab 实验报告12】聚类分析和判别分析
开发语言·数学建模·matlab·课程设计·聚类·实验报告
念恒123062 小时前
继承(下) (Inheritance)
c++
小陈工3 小时前
Python Web开发入门(十七):Vue.js与Python后端集成——让前后端真正“握手言和“
开发语言·前端·javascript·数据库·vue.js·人工智能·python
海清河晏1114 小时前
数据结构 | 单循环链表
数据结构·算法·链表
H Journey4 小时前
C++之 CMake、CMakeLists.txt、Makefile
开发语言·c++·makefile·cmake
wuweijianlove8 小时前
算法性能的渐近与非渐近行为对比的技术4
算法
研究点啥好呢8 小时前
Github热门项目推荐 | 创建你的像素风格!
c++·python·node.js·github·开源软件
_dindong8 小时前
cf1091div2 C.Grid Covering(数论)
c++·算法
AI成长日志8 小时前
【Agentic RL】1.1 什么是Agentic RL:从传统RL到智能体学习
人工智能·学习·算法
lly2024068 小时前
C 标准库 - `<stdio.h>`
开发语言