第十五周项目—阅读程序(4)
2016-06-18 09:23
316 查看
问题及代码:
运行结果:
/* *Copyright(c) 2016.烟台大学计算机与控制工程学院 *ALL rights reserved. *文件名称:main.cpp *作者:郝昱猛 *完成日期:2016年6月18日 *问题描述:阅读下面的程序 */ #include <algorithm> #include <functional> #include <iostream> #include <vector> #include<iterator> using namespace std; class myAdd: public binary_function<int,int,int> { public: int operator()(int a, int b) const { return a+b; } }; int main() { int a[5]= {1,2,3,4,5}; vector<int> my(5); transform(a,a+5,my.begin(), bind2nd(myAdd(), 4)); copy(my.begin(), my.end(), ostream_iterator<int>(cout, " ")); cout<<endl; transform(a,a+5,a,my.begin(), myAdd()); copy(my.begin(), my.end(), ostream_iterator<int>(cout, " ")); cout<<endl; return 0; }
运行结果:
相关文章推荐
- PPT动画教程:宏的应用和技巧
- swagger使用介绍
- Java 多线程 - 守护线程
- STL源码剖析——hash_set和hash_multiset
- Andrew NG 《machine learning》week 3,class3
- 团队总结
- Linux基础:Grep查询&AWK查询
- [PATCH] UBUNTU: SAUCE: (no-up) apparmor: Sync to apparmor3 - RC1(v3.4.x kernel)
- 给指定日期,年月日,获取一星期的起始日期
- 适配器模式(Adapter)
- Linux基础: 网络命令和进程管理
- 信息来解决模糊性
- Java注释@interface的用法【转】
- python 学习笔记 copy
- JAVA中压缩与解压缩
- [javaSE] 数据结构(队列)
- 让插入PPT的音乐跨幻灯片后同时播放
- copvalue from wrapper type to primitive type
- web Deploy网站发布
- 符号数和二者的互补