map: 1,定义 map<string,int> mp; 2.插入 mp.find(x); for(map<string, int>::iterator it = mp.begin(); it != mp.end(); it++) { cout << (*it).first << ” ” << (*it).second << endl; //按照key值从小到大输出所有元素 } mp.erase(key); //删除key对应的键值对。时间复杂度为O(logn) map<int, int>::iterator it = mp.find(key); mp.erase(it); //删除迭代器对应的键值对。时间复杂度为O(logn) mp.size() //返回map容器内元素的个数。时间复杂度为O(1) mp.empty() //返回map容器是否为空,如果为空,返回true。时间复杂度为O(1) mp.clear(); //清空map容器。时间复杂度为O(n)