第十五周实践项目阅读程序————3
来源:互联网 发布:布朗运动弹 知乎 编辑:程序博客网 时间:2024/06/17 13:29
问题及代码:
/*copyright(c)2016.烟台大学计算机学院 * All rights reserved, * 文件名称:text.Cpp * 作者:吴敬超 * 完成日期:2016年6月4日 * 版本号:codeblock * * 问题描述: * 输入描述: * 程序输出: 输出结果 */ #include<iostream> #include<functional> #include<numeric> #include<vector> #include<algorithm> #include<iterator> using namespace std; int main() { int a[]={1,4,7,2,5,8}; int b[]={1,2,3,3,2,1}; const int ASZ = sizeof a/sizeof a[0]; const int BSZ = sizeof b/sizeof b[0]; ostream_iterator<int> out(cout," "); copy(a,a+ASZ,out); cout<<endl; copy(b,b+BSZ,out); cout<<endl; int r=accumulate (a,a+ASZ,0); cout<<"accumulate 1:"<<r<<endl; //Should produce the same result : r = accumulate(b,b+ASZ,0,plus<int>()); cout<<"accumulate 2:"<<r<<endl; r=inner_product(a,a+ASZ,b,0); cout<<"inner_product:"<<endl; int *it=partial_sum(a,a+ASZ,b); copy(b,it,out); cout<<endl; it=adjacent_difference(a,a+ASZ,b); copy(b,it,out); cout<<endl; return 0; }
运行结果:
0 0
- 第十五周项目—阅读程序(3)
- 第十五周实践项目阅读程序————3
- 第十五周项目—阅读程序(1)
- 第十五周项目—阅读程序(2)
- 第十五周项目-阅读程序—1
- 第十五周项目—阅读程序(4)
- 第十五周项目—阅读程序(5)
- 第十五周项目—阅读程序(6)
- 第十五周项目—阅读程序(4)
- 第十五周项目—阅读程序(5)
- 第十五周项目—阅读程序(6)
- 第十五周实践项目阅读程序————1
- 第十五周实践项目阅读程序————2
- 第十五周实践项目阅读程序————4
- 第十五周实践项目阅读程序————5
- 第十五周实践项目阅读程序————6
- 第十五周阅读程序——3
- 第十五周项目二——阅读程序(1)
- 【VS】Visual Studio开发过程中比较常用的快捷键
- 第十五周实践项目阅读程序————2
- SAP医药医疗行业解决方案
- html table在使用中一些要点整理(持续更新)
- Ubuntu14.04 U盘启动盘的制作、Ubuntu14.04操作系统的安装、android开发环境的配置和android源码下载、编译
- 第十五周实践项目阅读程序————3
- C与C++结构体的区别
- iOS socket
- zz的世界,正常人不懂
- C语言循环结构_3
- 【ASP.Net】ADO.Net了解
- https通讯暨SSL学习笔记思路记录
- Android gt911触摸屏驱动移植记录
- 修改系统自带默认的输入法,系统自带键盘的样式