第15周阅读程序(4)
来源:互联网 发布:类似eve的网络手游 编辑:程序博客网 时间:2024/04/28 19:28
问题及代码:
/**copyright (t) 2016,烟台大学计算机学院*All rights reserved.*文件名称:test.cpp*作者:张晴晴*完成日期:2016年6月14日*版本号:v1.0*问题描述:阅读程序。*输入描述:*程序输出:*/#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;}
运行结果:
学习心得:
开始时候的加法运算给了数字4,意为序列里面的数都是与4相加再输出;
第二次的加法运算是序列里面的数与数列里面的数对应相加。
0 0
- 第15周-阅读程序(4)
- 第15周阅读程序(4)
- 第15周阅读程序(4)
- 第15周阅读程序(4)
- 第15周阅读程序(4)
- 第15周阅读程序(4)
- 第15周阅读程序4
- 第15周-阅读程序(1)
- 第15周-阅读程序(2)
- 第15周-阅读程序(3)
- 第15周-阅读程序(5)
- 第15周-阅读程序(6)
- 第15周阅读程序(1)
- 第15周阅读程序(2)
- 第15周阅读程序(3)
- 第15周阅读程序(5)
- 第15周阅读程序(6)
- 第15周阅读程序(1)
- arm-none-linux-gnueabi-gcc: 没有那个文件或目录
- redis中 string类型的操作
- Kodi ——6 Controls (9)6.9 Settings Spin Control
- Android的manifest配置
- mysql免安装配置启动
- 第15周阅读程序(4)
- 设置系统日期时间格式
- cuda-convnet 卷积神经网络 一般性结构卷积核个数和输入输出的关系以及输入输出的个数的说明
- 三色球问题
- 什么是垃圾回收(golang)?
- vim学习笔记
- java VisualVM 远程监控linux jvm运行状态
- ruby操作excel文件
- 1.Java开发前奏