pr22014.cpp
来自「c++编程宝典源码及Quincy99编译器 是《标准C++编程宝典》电子工业出」· C++ 代码 · 共 46 行
CPP
46 行
////////////////////////////////////////
// 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 + =
减小字号Ctrl + -
显示快捷键?