c++ transform算法

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

{

public:

int operator()(int v)

{

return v+100;

}

};

class MyPrint

{

public:

void operator()(int v)

{

cout << v << " ";

}

};

void test01()

{

vector<int> v;

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

{

v.push_back(i);

}

vector<int>vT;

vT.resize(v.size());

transform(v.begin(), v.end(), vT.begin(), Transform());

for_each(vT.begin(), vT.end(), MyPrint());

cout<<endl;

}

int main()

{

test01();

return 0;

system("pause");

}

相关推荐
Dlrb12114 小时前
C语言-指针三
c语言·算法·指针·const·命令行参数
kkeeper~4 小时前
0基础C语言积跬步之深入理解指针(5下)
c语言·开发语言
Tisfy5 小时前
LeetCode 2540.最小公共值:双指针(O(m+n))
算法·leetcode·题解·双指针
一直不明飞行5 小时前
Java的equals(),hashCode()应该在什么时候重写
java·开发语言·jvm
IronMurphy5 小时前
【算法四十七】152. 乘积最大子数组
算法
REDcker5 小时前
有限状态机与状态模式详解 FSM建模Java状态模式与C++表驱动模板实践
java·c++·状态模式
盲敲代码的阿豪5 小时前
Python 入门基础教程(爬虫前置版)
开发语言·爬虫·python
basketball6165 小时前
C++ 构造函数完全指南:从入门到进阶
java·开发语言·c++
互联科技报5 小时前
2026超融合选型:Top5品牌与市场格局解读
开发语言·perl
weixin199701080166 小时前
[特殊字符] 智能数据采集:数字化转型的“数据石油勘探队”(附Python实战源码)
开发语言·python