第15周阅读程序(3)

news/2024/7/7 1:34:23
/*
*Copyright (c) 2016,烟台大学计算机学院
*All rights reserved.
*文件名称 :
*作 者 : 刘云
*完成日期 : 2016年6月7号
*版 本 号 : v6.0
*
*问题描述 : 阅读程序
*输入描述 :无
*程序输出 :
*/

#include<algorithm>
#include<functional>
#include<vector>
#include<iostream>
#include<numeric>
#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+BSZ,0,plus<int>());
    cout<<"accumulate 2:"<<r<<endl;
    r=inner_product(a,a+ASZ,b,0);
    cout<<"inner_product : "<<r<<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;
}

运行结果;



http://www.niftyadmin.cn/n/3628389.html

相关文章

第15周阅读程序(4)

/* *Copyright (c) 2016,烟台大学计算机学院 *All rights reserved. *文件名称 : *作 者 : 刘云 *完成日期 : 2016年6月7号 *版 本 号 : v6.0 * *问题描述 : 阅读程序 *输入描述 :无 *程序输出 : */#include<algorithm> #include<functional> #include<iostream…

lightoj 1140 - How Many Zeroes?(数位DP)

1140 - How Many Zeroes? PDF (English)StatisticsForum Time Limit: 2 second(s)Memory Limit: 32 MB Jimmy writes down the decimal representations of all natural numbers between and including m and n, (m ≤ n). How many zeroes will he write down? Input Inp…

JS对象继承(6种)

原型链(父类的实例)借用构造函数(调用超类构造函数)组合继承(原型链和借用构造函数)原型式继承(借助原型基于已有的对象上创建新对象)寄生式继承(创建一个仅用于封装继承过程的函数)寄生组合式继承(解决父类属性重写)ECMAScript无法实现接口继承&#xff0c;只支持实现继承&…

第15周阅读程序(5)

/* *Copyright (c) 2016,烟台大学计算机学院 *All rights reserved. *文件名称 : *作 者 : 刘云 *完成日期 : 2016年6月7号 *版 本 号 : v6.0 * *问题描述 : 阅读程序 *输入描述 :无 *程序输出 : */#include<iterator> #include<algorithm> #include<functional…

Java的String字符串内容总结

String--字符串 获取字符串的长度 使用Sring类的length()方法可获取字符串对象的长度&#xff0c;例&#xff1a; str.length(); str代表指定的字符串对象;返回值为返回指定字符串的长度。例&#xff1a; 获取字符串中指定字符的索引位置 String类提供了indexOf()和lastIndexOf…

第15周阅读程序(6)

/* *Copyright (c) 2016,烟台大学计算机学院 *All rights reserved. *文件名称 : *作 者 : 刘云 *完成日期 : 2016年6月7号 *版 本 号 : v6.0 * *问题描述 : 阅读程序 *输入描述 :无 *程序输出 : */#include<string> #include<iostream> #include<map> using…

poj 3208 Apocalypse Someday 数位dp+二分答案

Apocalypse Someday Time Limit: 1000MS Memory Limit: 131072KTotal Submissions: 2203 Accepted: 1110Description The number 666 is considered to be the occult “number of the beast” and is a well used number in all major apocalypse themed blockbuster movies. …

emacs使用笔记

C-h t tutorial [移动基本操作]C-f C-b C-p C-n 前后上下 C-v C-a 行首 C-e行尾C-a 和 C-e 可以将光标移动到"一行"的头部和尾部。M-a 和 M-e 则将光标移动到“一句”的头部和尾部。M-f 向后移动一个单词 M-b 向前移动一个单词C-k 删除 C-v 下一页 M-v 上一页M-< …