第十五周项目1:阅读程序,领会STL用法(4)
2016-06-03 17:24
281 查看
问题及代码:
运行结果:
知识点总结:
这个程序涉及了类作为函数对象,向量,算法,看这个程序的时候还是有点吃力,有很多地方需要查相关资料。
学习心得:
自己的努力不会白费的,努力就会有结果。
问题及代码:
/*Copyright (c)2016,烟台大学计算机与控制工程学院 *All rights reserved. *文件名称:main.cpp *作 者:崔青青 *完成日期:2016年6月3日 *版 本 号:v1.0 *问题描述: *输入描述:无 *输出描述:无 */ #include<algorithm> #include<functional> //#include<numeric> #include<vector> #include<iostream> #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; }
运行结果:
知识点总结:
这个程序涉及了类作为函数对象,向量,算法,看这个程序的时候还是有点吃力,有很多地方需要查相关资料。
学习心得:
自己的努力不会白费的,努力就会有结果。
相关文章推荐
- 【Android】Android之命令行安装apk
- 在iOS中动态改变statusbar的颜色
- Column count doesn't match value count at row 1
- CSS3 filter 实现滤镜效果
- Linux中存储管理使用的数据结构和函数
- Caused by: java.lang.IllegalArgumentException: prefix wsdp is not bound to a namespace
- shell 脚本编程
- 促销书
- velocity基础教程--4通过velocity生成文件--网站静态化实现方案
- iOS开发笔记--使用blend改变图片颜色
- db2 清理表结构
- MySQL一个字段部分包含在另一个字段中
- android studio运行直接进入了上次打开的项目,没有第一次打开的选择窗口
- live555源代码分析
- blob分批次上传文件
- velocity基础教程--3用velocity代替jsp作为程序视图展示
- Python subprocess模块
- Parcel 写入boolean
- 传值和传址的区别
- Django里自定义用户登陆及登陆后跳转到登陆前页面的实现