![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++STL
攻城lion
这个作者很懒,什么都没留下…
展开
-
C++STL中的less和greater
greater() 和less()函数经常使用在sort()中用来对容器进行升序或者降序排序,或者用在push_heap()和pop_heap()中用来构建最小堆(greater)或者最大堆(less). 二者包含在头文件functional中 //包含在头文件<functional>中 // TEMPLATE STRUCT greater emplate<class...原创 2019-12-21 21:34:43 · 996 阅读 · 0 评论 -
list处理文件内容合并并去重,排序输出
问题:两个文本文件包含某中学的高考成绩,其中包含学生的准考证号、姓名、大学和总成绩。但两文件内内容有重复,现要求把两文本文件内容合并,去掉重复记录,并按准考证号升序排列输出。 #include <iostream> #include <list> #include <string> #include <fstream> #include <fu...原创 2019-11-17 18:05:22 · 427 阅读 · 0 评论 -
vector的综合案例(书籍作者 问题)
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <functional> #include <iterator> using namespace std; class Book { public: ...原创 2019-11-17 12:12:58 · 150 阅读 · 0 评论 -
字符串切割的两种方法
1、用字符串查找和substr #include <iostream> #include <string> using namespace std; int main() { string str = "How are you? "; string t = " "; string stresult; size_t size_pos = 0...原创 2019-11-16 22:13:16 · 769 阅读 · 0 评论 -
函数对象二元函数实例(包含sort、copy用法)
#include <iostream> #include <algorithm> #include <vector> #include <string> #include <iterator> #include <functional> #include <fstream> /* STL中二元函数基类是一个模板类...原创 2019-11-16 21:58:22 · 321 阅读 · 0 评论 -
函数对象一元函数实例
#include <iostream> #include <vector> #include <algorithm> using namespace std; /* STL中的一元函数基类 template<class _A, class _R> struct unary_function { typedef _A argument_ty...原创 2019-11-16 21:55:58 · 460 阅读 · 0 评论 -
C++for_each()的返回值
#include <iostream> #include <vector> #include <algorithm> using namespace std; /* for_each()它可以返回其仿函数(返回所传入的函数对象的最终状态). 这样我们就可以通过for_each()的返回值来获取仿函数的状态. */ /* 仿函数 */ class CSu...原创 2019-11-16 14:06:04 · 1476 阅读 · 0 评论