⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pr22016.cpp

📁 c++编程宝典源码及Quincy99编译器 是《标准C++编程宝典》电子工业出版社的光盘
💻 CPP
字号:
////////////////////////////////////////
// File Name: pr22016.cpp
////////////////////////////////////////
#include <iostream>
#include <map>

typedef std::map<int, char> MYMAP;

int main()
{
    // Create the first map object.
    MYMAP charMap1;

    // Populate the first map with values.
    charMap1[1] = 'A';
    charMap1[4] = 'D';
    charMap1[2] = 'B';
    charMap1[5] = 'E';
    charMap1[3] = 'C';

    // Display the contents of the first map.
    std::cout << "Contents of first map: " << std::endl;
    MYMAP::iterator iter;
    for (iter = charMap1.begin();
            iter != charMap1.end(); iter++)
    {
        std::cout << (*iter).first << " --> ";
        std::cout << (*iter).second << std::endl;
    }
    std::cout << std::endl;

    // Create the second map object.
    MYMAP charMap2;

    // Populate the first map with values.
    charMap2[1] = 'F';
    charMap2[4] = 'I';
    charMap2[2] = 'G';
    charMap2[5] = 'J';
    charMap2[3] = 'H';

    // Display the contents of the second map.
    std::cout << "Contents of second map: " << std::endl;
    for (iter = charMap2.begin();
            iter != charMap2.end(); iter++)
    {
        std::cout << (*iter).first << " --> ";
        std::cout << (*iter).second << std::endl;
    }
    std::cout << std::endl;

    // Compare the maps.
    if (charMap1 == charMap2)
        std::cout << "map1 == map2";
    else if (charMap1 < charMap2)
        std::cout << "map1 < map2";
    else if (charMap1 > charMap2)
        std::cout << "map1 > map2";

    return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -