C++ map的使用
#include <iostream>
#include <map>
#include <string>
using namespace std;
void main()
{
map<string, int > maps;
maps["gan"] = 10;
maps["quan"] = 100;
maps["fu"] = 1000;
cout << maps["gan"] << endl;
cout << maps["quan"] << endl;
cout << maps["fu"] << endl;
map<string, int>::iterator tem;
for(tem = maps.begin(); tem != maps.end(); ++tem)
{
cout << tem->first << " " << tem->second << endl;
}
int wait;
cin >> wait;
}
////输出
///**************************************
//** 10
//** 100
//** 1000
//** fu 1000
//** gan 10
//** quan 100
//**************************************/