18.5 常用集合算法
学习目标:
掌握常用的算术生成算法
注意:
算术生成算法属于小型算法,使用时包含的头文件为
#include <numeric>
算法简介:
accumulate
// 计算容器元素累计总和fill
// 向容器中添加元素
1 accumulate
功能描述:
计算区间内 容器元素累计总和
函数原型:
accumulate(iterator beg, iterator end, value);
// 计算容器元素累计总和
// beg 开始迭代器
// end 结束迭代器
// value 起始值
示例:
2 fill
功能描述:
向容器中填充指定的元素
函数原型:
fill(iterator beg, iterator end, value);
// 向容器中填充元素
// beg 开始迭代器
// end 结束迭代器
// value 填充的值
示例:
最后更新于
这有帮助吗?