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

}

相关推荐
longxiaozhang69 分钟前
C#运算符重载:让对象也能使用“加减乘除”
开发语言·c#
闲研随记13 分钟前
【文献阅读 ICLR 2026】RL算法:DECS
算法·llm·强化学习·iclr·rl
量化小c22 分钟前
一行代码查 BTCUSDT 和 AAPL 最新价?QuantDash 统一多市场实时行情接口实战
后端·算法·github
沙盘客37 分钟前
AFSIM 官方案例库全景与解读方法论
c++·经验分享·后端
机器人梦想家44 分钟前
具身机器人视觉服务的异步回调与并发控制
数据库·算法·机器人
mounter6251 小时前
GCCRS 突破与 Rust 入核:Linux 工具链的重大变革
linux·开发语言·rust·linux kernel·kernel
Buke..1 小时前
【APP 逆向】哔哩哔哩 sign 参数逆向(上):Frida 反调试绕过与 unidbg 调用
java·开发语言·爬虫·python·安卓
abcefg_h1 小时前
MCP 实战指南:如何在项目中使用 Model Context Protocol 及其通信原理
开发语言·后端·golang·mcp
何以解忧,唯有..1 小时前
Python 线程编程:从入门到实战
开发语言·python