STL练习程序(map...)

#pragma  warning (disable:4786)

#include <string>

#include <iostream>

#include <map>

using namespace std;



int main()

{

    string name[]={"tian","dsp","su","chu"};



    map<int,string> mapname;



    for (int i=0;i<4;i++)

    {

        mapname.insert(pair<int,string>(i,name[i]));

    }



    map<int,string>::iterator mapit;

    for (mapit=mapname.begin();mapit!=mapname.end();mapit++)

    {

        cout<<mapit->first<<"  "<<mapit->second<<endl;

    }



    system("pause");

    return 0;

}

你可能感兴趣的:(map)