![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
set/multiset
文章平均质量分 72
老鼠哎大米
这个作者很懒,什么都没留下…
展开
-
STL容器之字典排序
STL简单用法在 STL9中对vector 的习惯用法完全不同。我们不是定义一个已知大小的 vector,而是定义一个空 vector vector v;我们向 vector 中插入元素,而不再是索引元素,以及向元素赋值,例如 push_back()操作,就是在 vector 的后面插入一个元素,下面的 while 循环从标准输入读入一个字符串序列并每次将一个原创 2017-02-18 22:54:33 · 2242 阅读 · 0 评论 -
字典排序
存储一组姓名,要求能够排序,按字母顺序插入,并显示。#include #include #include using namespace std;void display(multiset sset){ multiset::iterator it; for(it=sset.begin();it!=sset.end();++it) cout<<*it<<" "; cout<<原创 2017-02-22 20:16:16 · 502 阅读 · 0 评论 -
某人有8角的邮票5张,1元的邮票4张,1元8角的邮票6张,用这些邮票中的一张或若干张可以得到多少中不同的邮资?
某人有8角的邮票5张,1元的邮票4张,1元8角的邮票6张,用这些邮票中的一张或若干张可以得到多少中不同的邮资? 两种思路:1.用数组方式,先求总数,然后排序,然后去掉重复数据,之后消除0,最后输出,求得不同的个数。2.直接用容器,比较简单。1.#include using namespace std;void sort(float a[],int n){ float tem原创 2017-02-27 12:51:08 · 3449 阅读 · 4 评论 -
处理学生信息
处理学生信息(学号 姓名 性别 年龄)要求:1.输入I 10 wes f 23 插入一条学生记录2.输入D 10删除一条学生记录3.输出结果按学号从小到大排列#include #include using namespace std;class student{ public: int num; string name; char sex; in原创 2017-02-17 21:38:23 · 515 阅读 · 0 评论 -
输入一组单词(区分大小写),统计首字母相同的单词的个数
set很好的利用了相同单词不累加的特性map很好的显示了统计特性,而且没有出现的字母不会插入到map#include #include #include #include using namespace std;main() { set sset; map cmap; string s; while(cin>>s) { if(s=="0"原创 2017-02-18 00:09:37 · 2783 阅读 · 0 评论