c++中的accumulate()

来源:互联网 发布:云建站淘宝客 编辑:程序博客网 时间:2024/06/08 04:04

一、accumulate()的最基本的用法

1、头文件#include<numeric>

2.使用方法:int sum=accumulate(a,a+n,0);其中,a为数组a[],n为数组长度,0为初始值。

  另外,该函数也可以把元素连接起来:string sun=accumulate(a.begin(),a.end(),string(" "));以空字符串开头,把a中的所有元素连接成一个字符串

二、自定义的一些使用方法


参考链接:http://www.cplusplus.com/reference/numeric/accumulate/

原创粉丝点击