参照算法笔记P213
#include<stdio.h>
#include<map> //map<typename1,typename2> mp;
using namespace std;
map<char,int> mp;
int main(){
mp['m']=20;
mp['r']=30;
mp['a']=40;
map<char,int>::iterator it=mp.begin();
for(;it!=mp.end();it++){
printf("%c %d\n",it->first,it->second);//按照key值升序
}
it=mp.find('r'); //find(key)
printf("%c %d\n",it->first,it->second);
mp.erase(it); //erase(迭代器)
mp.erase('m'); //erase(key);
it=mp.begin();
for(;it!=mp.end();it++){
printf("%c %d\n",it->first,it->second);
}
}