第15周阅读程序(2)

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

#include<functional>
#include<numeric>
#include<vector>
#include<iostream>
using namespace std;
int main()
{
    vector<int>v(5);
    for(int i=0;i<5;i++)
        v[i]=i+1;
    int sum=accumulate(v.begin(),v.end(),0);
    cout<<"Sum of values == "<<sum<<endl;
    int product=accumulate(v.begin(),v.end(),1,multiplies<long>());
    cout<<"Product of values == "<<product<<endl;
    return 0;
}

运行结果:



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

相关文章

LightOJ 1205 Palindromic Numbers(数位DP 回文数)

Description 求[a,b]中回文数的个数 Input 第一行为用例组数t&#xff0c;之后t行每行两个整数a和b表示查询区间端点 Output 对于每组用例&#xff0c;输出区间[a,b]中回文数的个数 Sample Input 4 1 10 100 1 1 1000 1 10000 Sample Output Case 1: 9 Case 2: 18 C…

C# 移动第一个重复字符到前面

例如 abcdbbfg 变成 bbbacdfg&#xff0c;要求时间复杂度为N,空间复杂度为1&#xff0c;写了两个方法都未达到要求 :( View Code static void MoveDupCharToFront(char[] input){if (input null|| input.Length <1){throw new Exception("input cant be empty or les…

XenDesktop多用户不同时间使用同一个发布的物理机桌面

XenDesktop多用户不同时间使用同一个发布的物理机桌面 Citrix XenDesktop 5.5发布一台物理机的OS桌面时&#xff08;非XenServer、VMware-ESX以及Hyper-V等虚拟系统&#xff09;&#xff0c;默认情况下&#xff0c;就算在创建桌面时将这个桌面赋予多个用户&#xff0c;当其中一…

Python迭代器和生成器(改编自知乎相关文章)

Python迭代器和生成器&#xff08;改编自知乎相关文章&#xff09; 1.迭代器 有一些Python对象&#xff0c;我们可以从中按一定次序提取出其中的元素。这些对象称之为可迭代对象。比如&#xff0c;字符串、列表、元组都是可迭代对象。 我们回忆一下从可迭代对象中提取元素的过程…

第15周阅读程序(3)

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

第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;只支持实现继承&…