STL(标准模板库)笔记---平衡二叉树map
本系列是观看北大郭炜老师程序与算法课程的笔记,用于复习与巩固。
map
map的用法
和multimap区别在于:
- 不能有关键字重复的元素
- 可以使用 [] ,下标为关键字,返回值为first和关键字相同的元 素的second
- 插入元素可能失败
#include
#include
map例题:单词词频统计程序
输入大量单词,每个单词,一行,不超过20字符,没有 空格。 按出现次数从多到少输出这些单词及其出现次数 。出现次数相同的,字典序靠前的在前面
输入样例:
this
is
ok
this
plus
that
is
plus
plus
输出样例:
plus 3
is 2
this 2
ok 1
that 1
#include
#include
#include