C++ STL中的accumulate函数
发布时间
阅读量:
阅读量
accumulate:
功能说明:用于统计指定区间内容器中所有元素的累加总和,同时支持对用户自定义的数据类型进行累加操作
算法概述:accumulate(iterator beg, iterator end, value); //用于计算容器中元素的累加总和
//[beg, end)表示区间的起始与终止迭代器,value为初始值总结:在使用accumulate时需注意包含头文件 numeric ,该算法在实际应用中具有较高的实用性
一、函数原型
template< class InputIt, class T >T //此时可以自定义数据类型
accumulate( InputIt first, InputIt last, T init );
template< class InputIt, class T, class BinaryOperation >T
accumulate( InputIt first,InputIt last,T init,BinaryOperation op)
在对**特定自定义数据类型执
全部评论 (0)
还没有任何评论哟~
