📄 pr22014.cpp
字号:
////////////////////////////////////////
// File Name: pr22014.cpp
////////////////////////////////////////
#include <iostream>
#include <map>
typedef std::map<int, char> MYMAP;
int main()
{
// Create the map object.
MYMAP charMap;
// Populate the map with values.
charMap[1] = 'A';
charMap[4] = 'D';
charMap[2] = 'B';
charMap[5] = 'E';
charMap[3] = 'C';
// Display the contents of the map.
std::cout << "Contents of map: " << std::endl;
MYMAP::iterator iter;
for (iter = charMap.begin();
iter != charMap.end(); iter++)
{
std::cout << (*iter).first << " --> ";
std::cout << (*iter).second << std::endl;
}
// Erase the map's second element.
iter = charMap.begin();
charMap.erase(++iter);
// Display the new contents of the map.
std::cout << "Contents of new map: " << std::endl;
for (iter = charMap.begin();
iter != charMap.end(); iter++)
{
std::cout << (*iter).first << " --> ";
std::cout << (*iter).second << std::endl;
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -