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

}

相关推荐
维吉斯蔡4 小时前
【VS Code / Cursor】文件夹右键快捷打开与文件类型自动关联
开发语言·程序人生·学习方法
luj_17686 小时前
星火科技助力边远地区防病攻坚
c语言·开发语言·c++·经验分享·算法
always_TT6 小时前
【Python 日志记录:logging 模块入门】
开发语言·python·php
xcLeigh7 小时前
Go入门:变量声明的五种方式详解
java·开发语言·golang
zmzb01037 小时前
C++课后习题训练记录Day175
开发语言·c++
啦啦啦啦啦zzzz8 小时前
工具:动态类工厂和用配置文件存储属性
c++·设计模式·工具·动态工厂
脱胎换骨-军哥8 小时前
C++ 代码规范与格式化指南
开发语言·c++·代码规范
枕星而眠8 小时前
C++ STL Map容器完全指南:从有序红黑树到无序哈希表
java·开发语言
geats人山人海9 小时前
数据结构第六章c语言 树的存储下二叉树的概念和存储
c语言·数据结构·算法
爱吃牛肉的大老虎9 小时前
Rust对象之结构体,枚举,特性
开发语言·后端·rust