C++ map容器的2种初始化方法
#include#include#includeusing namespace std;int main(){map map1;map1[string("tttt")] = 1;map1[string("ggg")] = 2;map1.insert(pair("niubi", 3));map::iterator it = map1.begin();
·
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main()
{
map<string, int> map1;
map1[string("tttt")] = 1;
map1[string("ggg")] = 2;
map1.insert(pair<string, int>("niubi", 3));
map<string, int>::iterator it = map1.begin();
while ( it != map1.end())
{
cout<<it->first<<" "<<it->second<<endl;
it++;
}
system("pause");
return 0;
}
更多推荐
已为社区贡献1条内容
所有评论(0)