#include<iostream>
#include<map>
#include<string>
using namespace std;
int main(int argc,char**argv)
{
map<int,char > aMap;
/**插入初始化的元素**/
/* //1.用insert函數插入pair
aMap.insert(pair<string, string>("r000", "student_zero"));
//2.用"array'方式插入
*/
aMap[0] = 'o';
aMap[1] = 'a';
aMap[2] = 'b';
aMap[3] = 'c';
aMap[4] = 'd';
aMap[5] = 'd';//故意弄个重复的value
int key =2;
char value='d';
//通过key找value
if(aMap.count(key)>0)
{
cout<<"通过key: "<<key<<" 找到的value:"<<aMap[key]<<endl;
}
//通过value找 key
for(std::map<int,char>::iterator it = aMap.begin();it!=aMap.end();it++)
{
if(it->second==value)
cout<<"通过value: "<<value<<" 找到的key:"<<it->first<<endl;
}
}