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


//**************************************/

 

posted @ 2013-06-22 19:24  Predator  阅读(211)  评论(0编辑  收藏  举报