c++ map运用

来源:互联网 发布:jquery post 提交数据 编辑:程序博客网 时间:2024/05/22 01:39
map<int, string> map1;
map1.insert(pair<int, string>(1, "apple"));
map1.insert(pair<int, string>(2, "banana"));
map1.insert(pair<int, string>(3, "crpit"));

//cout << map1.size() << endl;
map<int, string>::iterator mit;
for (mit = map1.begin(); mit != map1.end(); mit++)
{
cout << mit->first << endl;
cout << mit->second << endl;
}

原创粉丝点击