
C++STL中algorithm常用算法函数
介绍algorithm库中的常用算法函数,应用主要包括vector和string
周一写bug,bug改一周
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
C++STL中的求和函数accumulate()
C++STL中的求和函数accumulate() 1.1 函数原型及描述 accumulate(_InIt _First, _InIt _Last, _Ty _Val) _First和_Last累加的区间,_Val累加的初值。 返回类型跟_Val一致。 1.2 int中应用 输出数组中的和 vector<int> testArray = { 1, 2, 3, 4 }; int s...原创 2020-02-23 10:29:33 · 5101 阅读 · 0 评论 -
C++STL中algorithm里reverse()函数及swap()函数
C++STL中algorithm里reverse()函数 1.reverse()函数在string和vector中均可应用 1.1函数原型及描述 void reverse(_BidIt _First, _BidIt _Last) 将指定范围内元素重新反序排序。 应用例子 vector<int> testArray = { 1, 2, 3, 4 }; string subStr =...原创 2020-02-19 19:49:55 · 1026 阅读 · 0 评论 -
C++STL中algorithm里find()函数
string模板中的find函数 1.函数介绍 1.1函数原型及描述 函数1 size_type find(const string & str, size_type pos = 0) const 形参列表str:要查找的子字符串string变量,pos :要查找的起始位位置 返回为参数size_type :该子字符串首次出现时其首字符的索引;否则,返回-1 应用 string sub...原创 2020-02-19 19:29:54 · 588 阅读 · 0 评论 -
C++STL中algorithm里count()函数
C++中的count()函数 函数原型及描述 count(),存在于vector和string中,分别对单个数字和单个字符计数 用法 string mainString = "Let life be beautiful like summer flowers,death like autumn leaves"; int total = count(mainString.begin(), mai...原创 2020-02-19 18:48:31 · 567 阅读 · 0 评论